Better test to see if we're running in Node.JS without breaking CommonJS browser apps

A better check for Node.JS which takes into account the fact that some browser deployments may use CommonJS rather than AMD.