clean up; add tests