added avg, favg + corresponding tests and an internal flength function u...

...sed by both