I haven't run into this on the interviewee end, but my company has applicants work on real projects, and here's how we deal with it:
Pay them.
Pay them.
So if the company wants to have you write code to prove your mettle, have them pay you for the time.
That's the case here. One employer could severely abuse paying candidates for some quick job without any contract being even mentioned between the 2.
In most places it is standard boilerplate that your employer gets approval rights on any outside work you do while employed by them. Current employees also have more restricted IP agreements typically which can put the contracting company in legal trouble as well.
For this reason, I've found paid real work projects problematic in that it biases against the currently employed.