Files module: some refactoring (#506).

In preparation for "service method for other plugins allowing creation of files in filerepo".

See #506.