Small refactor, added more tests