First working version of rearranger for scala + tests for the rearranger