Part of the reason C code is so buggy is that it's so difficult to write test code for C programs.
Difficult to mock out functions. Difficult to only compile/include the parts of a unit that you want to test.
Difficult to deal with crashes in the test code (e.g. segfaults have to be thrown into a debugger to know where they happened).