Create common functions to reduce repeated code and modify some wrong test cases on fileutils