Added tests and documentation to fix of #17431.

- Credits for the patch go to ejucovy.