I was actually only in Singapore for the summer, so I had an American passport, but the train is different than most travel there for a few reasons.
Technically, I believe the train station in Singapore is Malaysian territory and run by the Malaysian company. They don't actually treat it this way, since it's a pretty building and something of a tourist attraction. What this means when you''re travelling is that, while they will stop the train at the Singapore border and stamp you out of the country, they sometimes forget to stop for 'entering Malaysia'. To be safe, keep your outgoing train ticket with your passport in case they raise an eyebrow leaving the country.
As for the visa, Malaysia doesn't require one for short-duration trips. I was fine for over a week; you should be fine for the testing day (or another few for sightseeing!)
I bought the train ticket day-of. In fact, I tended to buy them all day-of throughout the entire trip. However, the trip from KL to SG is sometimes harder to get the tickets you want last-minute, though in my case this was because of a national holiday in SG, so I'm not sure how difficult it is on a normal day. To be safe, you could just buy one on your way out of the KL station once you get there.
Hostels in Malaysia are also super super super cheap, if you don't think you want to add a ton of travel to your test day. You can usually get a private room for almost nothing (USD).
TL;DR: You just go to the train station, buy your ticket there, wait until the train gets there, board, and stop once at the SG border, then you're home free for KL. Save your ticket for reentry and enjoy!