Port test from cf1904f to avoid future regression

Related issue: #11939, #12084
Merge pull request #12436 from sikachu/4-0-stable-port-12084

Port test from cf1904f to avoid future regression