refactor and add test to scrabble