Finalized Tests and corrected sorting