clean up + fix bug
add tests