moved private createEnv to local lambda function in engine. Removed static_cast for unique_ptr