Added unit tests and fixed a bug along the way.