Added functionality described in issue #8 and the corresponding tests.

The functionality in issue #8 has been added. Tests for these methods have also been added.