Exact nonparametric inference for detection of nonlinearity