fix bug in variable resolver for conditionals and write some tests for it.