refactor manipulation of mongod in tests