Refactors and adds tests
Add to tests