Added unit tests for basic mongodb commands.
Fixed issues revealed by unit tests.