Look at global module cache rather than just main scripts immediate loads

I wanted to use this with `gulp-mocha` so patched it to look at the global list of loaded modules rather than just `require.main`.