code clean up
tests fixed