refactoring game code to be more testable

as well as more maintainable