Fix bug in canonical_test