Improve test coverage and clean up dead code.