Fix and tests for ERRAI-726.