Refactored Game.js and added tests for it