Pakistan beat New Zealand in 2nd test match