use File::chdir instead of Cwd

To avoid errors in taint mode.