PhantomJS workaround

Hi, @stephenhandley,

This is a workaround for PhantomJS strange behavior that returns `"[object DOMWindow]"` on `Object.prototype.toString.call(undefined)` and `Object.prototype.toString.call(null)`.

see: http://stackoverflow.com/questions/14218670/why-are-null-and-undefined-of-the-type-domwindow

Thanks!