clean up
add tests
abstract out testing framework