Add more test cases
Add integration tests and some bug fixes