Fixed issue with empty dirs
Updated test logic