I had two old iPhone 3GS's. One with a shattered screen. The other would shut down unexpectedly all the time. The folks at the Apple Store said the batteries were OK. Any flakiness was probably due to logic board problems.
I swapped the logic board from the shattered-screen phone to the flakey phone. The switch was easy. I used a jeweler's loupe to see things better. Unfortunately, the flakiness continued. It was different behavior, but not OK. So I ordered a new battery from iFixit. And that did the trick. Everything seems to be working great.
The #00 screwdriver was way too big. I got a #000 from my local hardware store.
Use a bright desk lamp and a jeweler's loupe. Those really help.
Also, the "do not remove" sticker inside the iPhone 3GS comes apart when you try to remove it. I used a pin to clean out the sticker bits that stayed stuck to the screw.
AND it is really helpful to magnetize the screwdriver. Otherwise it is tricky to get the screws to go into the right holes when you are putting the phone back together.