Count the number of htreads during tests to find leaks. See #2936