Test for result before dereferencing it