Fix write-mongo with unit tests.