CXX-189 Add tests and fix issues found while writing tests