We investigate two types of 405 nm (In, Al)GaN test laser structures (TLSs), one of them grown on SiC substrates, the other grown on low dislocation density freestanding GaN substrates. Measuring the lasing spectra of these structures, we observe an individual behavior depending on the substrate. TLSs on GaN substrates show a broad longitudinal mode spectrum above threshold, whereas TLSs on SiC are lasing only on one mode with various jumps of the laser emission at certain currents. Estimating the gain of each longitudinal mode with the Hakki-Paoli method, we find minute variations of the gain for TLSs on GaN substrate. In contrary, TLSs on SiC substrate show much larger fluctuations of the gain for individual longitudinal modes. Using a rate equation model with nonlinear gain effects, we simulate the longitudinal mode spectrum of both types of TLSs. Once we modify the gain of each longitudinal mode as observed in the gain measurements, the simulated spectra resemble the SiC or GaN substrate TLS spectra.