Remove dead code and add unittests to bring coverage back to 100%.