Merge pull request #23592 from pzygielo/23590

Extract and test method to construct message