Pass all tests, fixed calculation of mid.