Catholics will be able to represent the King to the Church of Scotland’s general assembly after MPs overturned a 325-year old law.