Refine tests, remove dead code