implement merge sort and refactor tests