Fix bugs in add_row, sort for multidim column, add tests