Refactor engine reconciler and add tests!

Done