Fix and regression test for ERRAI-672
Added unit test for ERRAI-672