Refactor and add new test