fixed statistics sorting
formatting
updated tests