Minor refactoring and implementation of ToObject/ToList/ToDocument(s) methods with tests.