Adaptive API hashrate reporting

The API will now report the hashrate in KH/s if it is below 1 MH/s. Also
consolidated some code into a function.