moved assign_ranks to its own utils file and added tests