This reverts commit ad164269e9aa7d0f39362d78d946a146dac5fdee and adds some additional tests. Fixes gh-24192