Remove dead code.
Adds tests.