Fixed localDir is null bug; added test