Refactor and additional testing