Make thread stress test more robust

Related to #21