Enhancements for MongoDB

Changes to help detect and fix some problems when running the MongoDB test suite.