Add Tests

This is a work in progress to add proper unit tests for all the functionality.