Add extra tests to threadtest3.
Add extra tests to threadtest4.c.  Fix a benign data race accessing the
text encoding using ENC(db).