Britons head home 'by skin of teeth' after prisoner swap