engine:

Refactored `run_calc` to make it easier to test.
tests/engine_test:

Added some tests to exercise the logic in `engine.run_calc`.

It was completely missing tests before.