There is a way to properly test software. But it is insanely expensive. Real mission critical software (like airborne systems) has standards for code verification that are pretty tough. For example per standard DO-178B, required is complete structural coverage analysis; object code analysis; worst case throughput analysis; stack analysis, etc.
There's no way that volunteer programs can find funding for this or human resources to do this. Although many companies do contribute to various open source programs, the level of testing required to remove most of bugs is extremely costly. Who's going to pay for software to be nearly perfect, if it is not required of it? Truth it, pretty much nobody outside mission critical software does this kind of testing.