[r2] Fix false positive when ERROR is generated but catched by tests

Build on top of #88.
Closes #43 for r2 (must be later forward ported to master).