A few fixes for issues reported in static analysis.
rm -rf needs to chmod directories to u+rwx, because directories need +x to search.
(Fixes messages about not being able to delete directories when running make test).