Added tests, changed implementation to use a sort-of linked list