Thanks to amosonn at yahoo.com for the report, @doda for the initial patch and @datagrok for the revamped logic and test case.