I think this line should read `if (isObject(x)) {` - no reason to exclude nil, and in the case of x being null instead of an object you'll get an error here before it reaches your nice 'Expected Object, ...' error message.