Ministers defeated on call to take back railways