tdb: fix warnings with gcc -O3, and one test crash.