Make check script more robust