Fix bugs #240 and  #296, parameter substituion troubles

Hey guys,

Here's the fix for bugs #240 and #296.

I somehow managed to overlook single quote escaping in quoted sections when I re-wrote the query parameter substitution logic,  Luckily it was a straight forward fix.

No regressions found when running the tests.

-Glen