tests: fix error reporting from Mkdir calls

Whenever the creation of a directory fails, it was trying to report an
error from an outer scope.