Fix #3693 (variable ref'ed before assignment)

Also, fix another reference before assignment in the "test=True" code
block