Are you entitled to be paid for your work? Yes. Do you have a case against them? Probably yes. Is it worth your time? Probably not.
I'm guessing we're talking about a pretty small code test that took you maybe a day tops, in that case it's really not worth putting yourself through the ringer just to prove a point. Yes, they're assholes for doing this, but as many have said before, the best revenge is your own success without them.