Unions agree Labour should back remain in referendum on Tory deal