* fix merging condition in merge_dims * add tests * set contiguous after mask is canonicalized * minor fix