filetesting: factor out from juju-core

Including commit history, hence not rebased.