Fix list()

Fixes the list() function and adds test for it.