Remove dead code and fix test