refactoring to improve mockability for mongo layer