fixes and tests for thread safe data structure