Fix a number of compiler ICEs

Also adding tests for fixed ICEs