Implemented gradient testing, untested