[CB-2213] Added a test for getParent.
[CB-2232] Added specific expected error checking.

Also did some refactoring.