Add regression test and fix