problem 4 code and tests