Repro unit test for #296

(cherry picked from commit b1a03781a4ad44c2044f9f195dafaa7bc50f2d48)

Backport #307 from master
Simplfied repro unit test bugs #240 and #296

This is about as simple as I can make it.

(cherry picked from commit 0d13218968f59a3a013429570a51e83e95341540)

Backport #307 from master
Fix for bugs #240 and #296

Properly handle escaped single quote character ('') in a quoted section during query parameter substitution.

(cherry picked from commit 253b6f99c014cc6bd8cea096776dbc088e66fa33)

Backport #307 from master
Bugs #249 and #296 Unit Test Improvements

Use close approximations to the repro queries supplied for these bugs, in addition to the simple one devised for diagnosis.

(cherry picked from commit d45f620955d02bd04b263d04cfa77db53fbeec0d)

Backport #307 from master
Remove debug/logging code.

(cherry picked from commit 5ec17bb6d03473718c946d2221eb6f8d79f52246)

Backport #307 from master