Add some tests, refactor
Add some tests, refactor