Make teardown more gracefull.

Add tests for unexpected modification of TestCase.app attribute.