Unrevert r195599 with testcase fix.

I'm not sure how it was checking for the wrong values...
PR18023.