cleaned up a little code and tests