fixing issue [#50] and writing regression tests for this issue