refactor: check required global variables only once

Moving checks to a wrapper in order to:
* avoid executing them on each call to `require`
* don't execute "load all modules" logic under tests