bug fix revealed by test script written by @snacktavish