Merge tests for issue 3940
Merge tests for issue 4403