Refactored Mongo connection to test for environment