File rearrangement and some tests