[FIX] tests: make sure that a failed tests do not leave the environment dirty

When a failure occurs, or when exiting an assertRaises(), the environment
should not contain fields to recompute.

Fixes #3056 #3422