Better test code for issue/51.
Merge mzp's patch. (fixed #51)