More unit tests, including fixes found during testing.