Testing for callbacks thread safety in C++