Issue #7792 made `x < I` different from `I < x`: fix and add tests

I noticed that #7792 makes `I < x` raise an error.  But `x < I` is unevaluated.  Here's an attempt to fix.

Also, add tests.
Ok (a little more pedantic: "issue 5724" will be more consistent with the rest of code).  Please rebase and fix commit message (Issue #7792 is not an issue).