Refactor and add two more tests