Implement remaining semantics checks and add many more tests