Add more  tests; fix errors