Done some refactoring and added more tests.