bug with multiple threads fixed, unit tests updated