Function doc and tests

Function documentation modified according to Stof's coments.
Tests added.