Certifiers have to adhere to, and impose, a set of rules and regulations. Are you really asking who decides what those rules and regulations actually are? Where does the buck finally stop?
Inevitably a committee using combined experience and knowledge since the first plane flew to decide what planes and their systems should be able to do and withstand.
As said, with new technologies such as LiPo batteries and carbon composites, experience comes with use and if manufacturers had to wait 10 or 15 years to allow time for all possible bugs and design glitches to be ironed out we probably wouldn't have such advanced aircraft flying today. It could be argued that manufacturers are trying too much too soon to get better aircraft to market ahead of the competition, but aircraft design is still conservative, despite the advances in technology.
It's in nobody's interest to put a plane in the air with inherent flaws, and, perhaps with the 787, risks were taken with batteries that weren't wholly understood, but the containment systems did what they were meant to. Live and learn.
And all the flight tests in the world can't reproduce the daily grind of actual service so you're never going to find all the niggles in a new design until it's flown for real for a while.
wheat and dairy can screw up your brain