fixed test for problem 27, refactored problem 30