Alastair Cook was in top form as he helped England on their way to a narrow victory over New Zealand.