added more multithreaded tests that are useful with tsan

Also made various small cleanups while writing and checking these tests.
diff --git a/aos/common/util/thread.cc b/aos/common/util/thread.cc
index fab62eb..dbb638e 100644
--- a/aos/common/util/thread.cc
+++ b/aos/common/util/thread.cc
@@ -1,7 +1,8 @@
 #include "aos/common/util/thread.h"
 
 #include <pthread.h>
-#include <assert.h>
+
+#include "aos/common/logging/logging.h"
 
 namespace aos {
 namespace util {
@@ -10,24 +11,30 @@
 
 Thread::~Thread() {
   if (started_ && !joined_) {
-    assert(false);
+    CHECK(false);
   }
 }
 
 void Thread::Start() {
-  assert(!started_);
+  CHECK(!started_);
   started_ = true;
-  assert(pthread_create(&thread_, NULL, &Thread::StaticRun, this) == 0);
+  CHECK(pthread_create(&thread_, NULL, &Thread::StaticRun, this) == 0);
 }
 
 void Thread::Join() {
-  assert(!joined_ && started_);
+  CHECK(!joined_ && started_);
   joined_ = true;
   {
     MutexLocker locker(&should_terminate_mutex_);
     should_terminate_ = true;
   }
-  assert(pthread_join(thread_, NULL) == 0);
+  CHECK(pthread_join(thread_, NULL) == 0);
+}
+
+void Thread::WaitUntilDone() {
+  CHECK(!joined_ && started_);
+  joined_ = true;
+  CHECK(pthread_join(thread_, NULL) == 0);
 }
 
 void *Thread::StaticRun(void *self) {