Extract common fs operations to fs-utils, add tests