Write solutions to problems 1 and 2 and fix test case for problem 2