add gradient test

The second gradient isn't quite working, as the projection isn't applied
to the operator correctly.