Add tests for issue 5113

Complete PR 2376

fixes #5113