Implemented unit tests

In copious amounts.