Issue #2193421 by joachim: Add tests for hook invocation and Rules event triggering during flag/unflag.