Minor refactoring, added more tests, removed unused dependency.