Added some tests and fixed the winning condition.