remove dead code, add unit tests