Refs #4247 Adding unit test + fixing "visit" custom variable scope