Refactoring. Add test case