Add tests, fix all brokeness