Integrated shutil.rmtree() into tests.

Use shutil.rmtree() to remove nonempty directories; os.rmdir() works only for
empty directories.