Fix assorted memory errors in imgproc's tests