Add tests, refactor views