Remove dead code, increase test coverage