Obama: North Korean nuclear test 'a grave threat'