Fixed an incorrect condition in Index#retrieve and added that `nil` is returned for 404 responses

This fixes #939.