Improve CommonJS Enviroment check