I have not applied the patch, but this bug is fixed; other changes related to validation (
TAP5-22) have eliminated the exception ... I was able to verify your problem exists under 5.0.15, but it is not present in 5.0.16-SNAPSHOT.
I was not happy with the patch, since I feel strongly that whatever is put into the environment in a begin/before method (or equivalent) should be cleaned up immediately inside the matching after method (or equivalent). There is the risk that the pops may occur in the wrong order, leading to very difficult to diagnose incorrect behavior.