Fix a bug where a returned handle to a derived JS object would not always correctly increment the reference count of the underlying smart pointer.