Refactored 3rd challenge into a class and added a test