Added check for winner and tests for it, little refactor on the main function