adding 'make check' target
Improving thread management