Add new threadlocals (old api still there).

Signed-off-by: Michael Lippautz <michael.lippautz@gmail.com>
Fix test compilation.
threadlocals -> ThreadContext (new api)

Signed-off-by: Michael Lippautz <michael.lippautz@gmail.com>