Fixed regression introduced in previous pull request

fix and unit test