The electric carmaker benefited from a potent weapon for improving its income statement: regulatory credits.