implemented moving average algorithm and tests