Fixes #1023 - setFile() can also take string, refactoring