Why are you cleaning up your resource? That is not the task of this test.

And I would not use the if/else approach, see previous comment.