Cleaning up isWin code and adding more unit tests.