add tests; remove obsolete code