added unit tests for game and small refactoring