Added 'when' and a small set of tests associated with the function.
Merge pull request #16 from smbache/master

Added 'when' and a small set of tests associated with the function.