All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Your doubting that you had committed an act of Kufr that has taken you out of the fold of Islam is not Kufr. The basic principle is that you are Muslim; this is a fact that is established with certainty. Certainty is not overruled by mere doubts. Beware of Waswaas; verily, getting carried away with it leads to grave evils. You have to strive against this Waswaas, and whenever the devil whispers to you in this regard, push it away and disregard it completely. This is the only treatment for the Waswaas which you are suffering from. We ask Allah to bless you with a perfect recovery.
Allah knows best.