Correct another ternary operator issue and add test cases for it.

  The problem was related to the logic not understanding that the left
and right expressions execution are exclusive, and getting confused
when evaluating the right operand and spill/reloading the left value.