Slight refactoring. added test class