Added conditional tests and refactored directory handling