Introduce ResultType and improve static typing in test_engine.py