Proposals to further delay the date of Brexit have moved closer to becoming law after they squeaked through the Commons by one vote.