I don't think you still need this custom PBLoader except for the console hook, and the right way to do it that would avoid all magic require statements being written before is to do like this:

```
function LoaderWithHookedConsole(module) {
  let errors = [];

  let console = Object.create(console, {
    error: {
      value: function(e) {
        errors.push(e);
        if (!/DEPRECATED:/.test(e)) {
          console.error(e);
        }
      }
    }
  });

  let loader = Loader(module, {console:console});

  return {
    loader: loader,
    errors: errors
  };
}
```
And then, in tests, do this:
```
let { LoaderWithHookedConsole } = require("private-browsing/helper");
let { loader, errors } = LoaderWithHookedConsole(module);
let windows = loader.require("windows");
```
The important trick is to pass to Loader constructor the `module` object from where you do call require(something).
So here, the module object for test-something, instead of private-browsing/helper.