Adding tests, refactoring and getting in order