Malaysia's economy expanded 4.0 percent in Q2, the slowest pace in nearly seven years, as exports and domestic investments were weak.