Simplify implementation and testcase of r223401 based on feedback from dblaikie.