The Court of Appeal has overturned two High Court injunctions preventing trade unions ASLEF and the RMT from striking.