So the problem remained with the Z axis? That's actually good news, since it means that the problem is probably a mechanical one, wiring, noise, or a settings issue and not the fault of your controller or driver. If it's just faulting when you do a rapid upward move and you're sure your velocity and acceleration settings are correct, that points to stiction of some kind - check again to make sure there's no binding at the top of the stroke. Check to see if any wires are stressed in these upward moves, or if they could be losing their ground connections. There could also be some kind of noise coming from your spindle. To check that, try running the problematic part of your program with the spindle turned off.