Add detect and tests