Added small unittest. Threading issues are hard to test.