Fixed action beforeRun/afterRun calls.
Fixes #2552.