Fixes #800. check instanceOf new Primitive(), not typeof

fixes #800. check instanceOf new Primitive(), not typeof