EU court rules against 'benefit tourism'