Tests: add error == NULL checks everywhere