Additional checking for testing environments

In some testing environments (angularjs mocks, Qunit), module is a global variable but is not the same as a commonjs module definition object (i.e. does not have module.exports). In such cases, this change adds additional checking for a global exports object as well. The combination of the two is a better inidication whether we are in a commonjs environment. 

Issue: #417