Fix logic problem in unit test