[src][test] Fixing a bug and introducing a test where prepending to a list would orphan the tail of the list