Add some test before executing file operations

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>