Create subdirectories if necessary.

Fixes the last failing test.