minor code cleanups
add some more tests