New unit tests

Partial completion of #168 

-Adds some new unit tests that target the unit/function level
-Does a bit of refactoring/debugging to address things the unit tests found