I would suggest change the data structure in the unittest. comments on the code below