Using `l->next` as a test for whether only one element is left in the list is not reliable. Use the actual list length instead. Update one affected test. Closes #1961 Change-Id: I5773715700220cd762e61090bac941ddd33afd9b