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.