Added a few unit tests and fixed a bug.