Add verification before adding a file (+ tests)

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