Add unittests for the exceptions,

And use only lstat in exists.