Add merge slices functionality

Add the function rebuild_image() in order to merge the slices of a partitioned image.
Add a basic test to to check the function.