BUG: Check earlier for higher priority in binary operators, add test

Fixes #3375