added test for % in variable substitution and fix