Add tests for issue 5113

Complete PR 2376