Move quoting to else block only for valid vars. Add test case.