Add a test with sliced encoding

This serves as a simple test of the thread library.
Merge pull request #391 from mstorsjo/threaded-test

Add a test with sliced encoding