Fix and improve test coverage.