Fixed situation where a collection is replaced by a null instance and added tests for onCollectionUpdate and onCollectionRemove and remove for detached objects
Fixed situation where a map is replaced by a null instance and added tests for onCollectionUpdate and onCollectionRemove