added test file and inversions counter to the algorithm