Writing tests and fixing some small bugs.