Add unit tests using boost test

Added UnitTests for a few classes, as well as fixing some minor bugs and cleaning up a little bit in the process.
Can we move the initialization out of the query? Having the query const was a good guarantee.