logging
clean up and adding unit tests