Fix while loop error reporting and set equality

Errors in while loop tests were being reported on the last line of the previous iteration.

Set == and != were not working correctly.

Sorry for combining these in one pull request, but they are both small and simple.