Refactored the engine class to be more specific about the implementation. Added engine unit tests.