Add tests for check refs and other things