add test and code for problem 9