fix #21600 fix #21889 and add regression tests