New Zealand beat India by 40 runs in first Test