Debugging, refactored and ran tests