Additional tests and cleanup to improve test coverage

These changes improve test coverage to 80%.