Fixed renaming parent directories and added tests.