More robust checking for environment, previous solution failed still showed errors when RequireJS is used in the testrunner