Add tests for semantic cleanup