legendre test works