Update the 2.x patch with the last version uploaded to rietveld (patch set 5).
Improved test coverage with upstream tests and tests cases provided by Neil on issue #6232.
Note: the patch for 3.x is obsolete.