fixed compatibility for NodeJS environment

Alright, this fixes #34 and doesn't throw an exception anymore. As the bonus the exported function has `nodom` boolean property so we are able to check in tests without waiting for the callback that never gets called.

Detection of environment came from [this article](http://timetler.com/2012/10/13/environment-detection-in-javascript/).