Church of Scotland upholds gay minister's appointm