fixed validating path (+ ending "/" only for dirs)