Moved median to common.
Use partial sort for Median and test.
Merge branch 'MAID-359_account_transfer' into MAID-313_test_account_updates
Reinstate and update tests. Avoid potential overflow in Median calculation.