If it only stays powered on when connected to a charger then the battery is failing and should be replaced. I know you say software tells you your battery is ok but that is not always accurate. If you have a device with a failing battery they can start doing odd things. So how can you trust the software is correct when your phones shuts off at random charge levels. This to me points even more to a failing battery. Especially after the steps you've taken to try and diagnose a software battery calibration issue. So I do recommend replacing the battery.