Refactor some code out of MongoDBRiver. Better readability and testability and will help with retrying connections to DB