MovingAverage bug and unit test for issue #1538

@scottpurdy please review.
nit: no spaces around `=` for function params