Support IO lists

Adds support for IO lists. This should also increase performance quite a lot (since `++` is no longer used everywhere).

The test suite is also refactored.