debug and cleanup
rewrite tests on inputs