This function was added in commit 20553b14 in the wrong place, with the wrong name, and without tests. Fix all that.
20553b14