For ENG-4396 and friends, fix bugs in mapping from hashed value to partition, add tests cases for boundry conditions