I'm sorry for your loss. I would do a bigger water change than 30% just to be sure, since your nitrates were at 40. Assuming they are still around 40, a 50% change would bring them down to 20, 75% would bring them down to 10. The lower the nitrates, the better. It doesn't look like your fish had anything contagious, and from your story about the water change I'm guessing there was some contamination that brought about his ill health and made him more susceptible to fin rot from the water quality. I'm guessing it was a little worse than the strips say simply because that was a fairly large looking fish with a very heavy bioload in a 10 gallon tank. Before restocking I would advise getting your own liquid test kit (around $18 on amazon) so you can better monitor your water quality. In the long run, the liquid test is cheaper than strips anyway, and it works better. You get way more tests out of a kit than you do a tube of strips. When you do restock, avoid goldfish. The are messy fish that get way too big for a 10 gallon. Even the fancy types need 20 gallons as a bare minimum, and many will outgrow that. Common goldfish need at least 55 gallons for just one fish. They get huuuuuuge. I would add a few more guppies and maybe 4 dwarf cories. Someone correct me on this if the cories won't fit, I'm not all that experienced in stocking small tanks.
Edit - yeah that Pleco needs to be rehomed. I didn't read down to where you confirmed it was a Pleco, I was thinking maybe it was a Chinese or Siamese algae eater... Although those really get too big for a 10 too. If I were you, I would go ahead and get a larger tank, maybe a 30 or 40 gallon if you don't want to jump right in with a 55. You will have way more stocking options, although a common Pleco still would be too big, and more water volume to work with. More water means waste is more diluted and you have more room for error. Then you can also keep the 10 you have for a quarantine / hospital tank.