A NASA official says the explosion of SpaceX’s ship during a test ‘was a huge gift’ for making the vehicle safe to fly