Add more tests and fix detected bug to make these tests pass