Added tests for engine, also fixed #1