clean out the code a bit
add tests