Throws a JS error when Object.keys is invoked on non-object. Fixes #303