Welcome to Fish Lore.
I'm really sorry about losing your fish, but congrats on the babies.
I know you said you only have one question but it would help for you to know why the other fish died.
When you say your water tests fine, what are the exact readings for ammonia nitrites and nitrates?
To help understand what happens in a new tank here's a link explaining the
nitrogen cycle.
http://www.fishlore.com/NitrogenCycle.htm
The link Dozey gave you is an good way to cycle a tank.
I agree with the Mike, the swordtails should have a larger tank.
Good luck