Cleanup mongodb authentication

Authenticate to the database before getting a reference to the
collection.