Add guard for auto testing
Refactor tests