tensor: bug fixes in insert