More changes for #162

Added new module Stats, moved moving and now expanding window
functions there, wrote tests.