Add tests and fix bugs
More tests