Refactor hook handling in ResourceLoaderTest