Add tests
Fix bugs from failing tests