The spirit of the law is much different than the actual law. What these companies are doing isn't illegal.
Closing these loopholes may bring in some more revenue in the short-term, but if it no longer makes sense financially, they will just move their HQ to another country completly.