Match the spec properly

Fixes #1 and #2.
Please use `typeof` or `Object.prototype.toString` here; `instanceof Function` won't work across realms.