Fixed small issues and added more tests.