improved tests and some additional cleanup