The code for mapping slices to chunks is wrong for some cases. Fix code and add additional chunking tests to cover edge cases.