better handling for custom kernels for quadratic time mmd

and updated unit tests