Fixing testing and build with static link

Threads don't work with static link, though :(