Added more tests.
Bug fixes