Refactoring
refactored and fixed tests