Added unit tests for the domain objects and fixed some bugs.

All of the domain objects have individual unit tests. This resulted in a few bugs being found and fixed.