Some fixes

Same patch that I submitted to Blaze earlier (cherry-picked from that repo, in fact) plus a fix for the tests: on <del>Linux w/GCC</del> some Linux distros (apparently others work fine), you have to pass `-pthread` to both the compiler and linker to get POSIX threads, or they simply won't link.

Haven't tried this on any other platform, but IIRC, this was also necessary to get pthreads on OpenBSD so other BSDs may be similar.