Added more tests
More tests and optimizations