MovingAverage bug and unit test, Fixes #1571

@scottpurdy please review.
Fixes #1571
//EDIT: added the "fixes.."