Refactor openfmri, checkhash, add tests