Check with-handlers better in TR

Now checks that a predicate and handler in the same clause
are consistent (using the filter on the predicate).

Closes PR 13950
Closes PR 14641