fix KroneckerDelta not canonical (issue 3479) and added new test