added doctest for most functions and test.sh script