Cleaning up analysis module and adding tests

Addresses #128