Fix null ObjectId in createObject() and modifyObject()

(Because typeof null === 'object' returns true)
It would try to access ._id of a null object which would throw a TypeError.