add layer test case

moved mkdir() method to IoUtils to ensure the directory hierarchy always
exists before writing cumulative and references files
fix class cast error
move each patch element contents in separate directories inside the
patch