added tests, pruned dead code