Unit test for new functions

Unit tests written and a wee fix for an issue that they pointed out
(yay!)