Added tests and made main game loop better.