Fix
refactoring and new test