Extract splitContainerAndKey method and add tests