I don't know how the test could be wrong.  Whenever this chunk of code is reached, list just happens to contain a single item.  When `uniq` is called on that list, it returns an empty array when doesn't make sense given there is only one item in the list.  This condition seems to handle it by all accounts that I was able to test and try.  I know it seems ugly, but it works.