refactor mongodb config instantiation