Added new functions and tests.

https://gist.github.com/dpolcyn/a615a2896c9b597fe6af#file-gistfile1-txt