Tests, some refactoring, updated readme