#369 Fixed with unit test.

Please, review.