Add some tests. Refactor.