Fix bug where exception is thrown for non existent directories

Change-Id: I49e96d8cadaa5bb9ae85f918b46292ddecaef4d9