#1995 Backport fix and test to maintenance-3.x branch
Merge pull request #2151 from kennymacleod/maintenance-3.x

#1795 Backport fix and test to maintenance-3.x branch