Add tests for bug#1457
Incorporate changes from CC#2055