Completed unit test for InvitationsManager

Improved error handling and optimised access to datastore