Another bug fixed with unit tests