Fix buggy test for nowiki escaping quotes

* 'a:b'foo was getting serialized to <nowiki>'a:b'foo</nowiki>
  because of a buggy test in the wikitext escaping code.

* Refactored code to reuse the tests in couple places.

* Fixed it + added a new test to catch regression.

* Regression found during RT-testing.

Change-Id: Ic1bec1f2c5621998e2fc0e18547a9912db487769
Merge "Fix buggy test for nowiki escaping quotes"