Ensure that the target directory exists, with error checking turned on.
Add test to check the installation on new directories.

Also fixed the indentation.