Refactored 4th challenge into class and added a test