Well, in case labour laws prevent people being paid for some labour -- or if the applicant needs to be registered as an independent contractor in order to receive payment for the work -- can't the company just pay for the expenses (and a little extra) and thus compensate the applicant sufficiently? It should be possible to pay for travel, stay, lunch or other 'inconveniences' in case the labour/deliverables can't be paid for directly, right?
In my country the potential employee would have to be registered as an independent contractor before being able to charge for the provided service. And then if he wanted to become a full time employee he'd have to unregister as a contractor.
So if the company wants to have you write code to prove your mettle, have them pay you for the time.