cleaned up code and tests