Fix undefined index error recomputing changesets for documents without one
Rewrite #897 fix and test to be consistent with ORM

This makes the test more in line with the corresponding ORM fix in doctrine/doctrine2@d473824279bfee19772bb1692d2a3453a2aff233. Our lifecycle callbacks to not yet receive event arguments, so the DocumentManager must be injected into the document manually (yes, this is a hack).
Merge pull request #897
Test to prove, that when calling merge twice on the same detached document a spl_object_hash collision occurs.
Detach old managed copy as no more references on it