This was detected by
NXMOB-238: the document returned by the Document.AddToFavorites operation was showing false for the isFavorite enricher although it had actually been added as a Favorite.
This was due to the use of a temporary DocumentModel in
that forced the need to re-fetch the document from the session once added to a collection to get a fresh state, which was done in the tests, but not in Document.AddToFavorites:
The fix allows to remove these extra doc = session.getDocument(doc.getRef()) calls from the tests.
Note that the problem didn't happen when removing a document from a collection because there is no such use of a temporary DocumentModel in