Potential bug corrected with unit test.