Trapping and acceleration of nonideal injected electron bunches in laser wakefield accelerators