clean up code and tests a bit