Fix tests, add test coverage.