diff --git a/modules/core/src/Controller/ErrorReport.php b/modules/core/src/Controller/ErrorReport.php
index 1afb833c54ceaa24d4362761be640f4c66108323..cd9e00e2174978042aec1dc431e0558f6cea6cd7 100644
--- a/modules/core/src/Controller/ErrorReport.php
+++ b/modules/core/src/Controller/ErrorReport.php
@@ -9,6 +9,7 @@ use SimpleSAML\Configuration;
 use SimpleSAML\Error;
 use SimpleSAML\HTTP\RunnableResponse;
 use SimpleSAML\Logger;
+use SimpleSAML\Session;
 use SimpleSAML\Utils;
 use SimpleSAML\XHTML\Template;
 use Symfony\Component\HttpFoundation\Request;
@@ -30,6 +31,9 @@ class ErrorReport
     /** @var \SimpleSAML\Configuration */
     protected Configuration $config;
 
+    /** @var \SimpleSAML\Session */
+    protected Configuration $session;
+
 
     /**
      * Controller constructor.
@@ -37,11 +41,13 @@ class ErrorReport
      * It initializes the global configuration for the controllers implemented here.
      *
      * @param \SimpleSAML\Configuration $config The configuration to use by the controllers.
+     * @param \SimpleSAML\Session $config The session to use by the controllers.
      */
     public function __construct(
         Configuration $config
     ) {
         $this->config = $config;
+        $this->session = $session;
     }
 
 
@@ -66,10 +72,10 @@ class ErrorReport
             throw new Error\Exception('Invalid reportID');
         }
 
-        $data = null;
         try {
             $data = $this->session->getData('core:errorreport', $reportId);
         } catch (Exception $e) {
+            $data = null;
             Logger::error('Error loading error report data: ' . var_export($e->getMessage(), true));
         }
 
@@ -82,7 +88,7 @@ class ErrorReport
                 'referer'        => 'not set',
             ];
 
-            if (isset($session)) {
+            if (isset($this->session)) {
                 $data['trackId'] = $session->getTrackID();
             }
         }
diff --git a/modules/cron/src/Controller/Cron.php b/modules/cron/src/Controller/Cron.php
index 80346cd1217478f1fd27e28dedf45f9143aed345..5772d4e7b3154b537843f1cc891e63b3a9815e14 100644
--- a/modules/cron/src/Controller/Cron.php
+++ b/modules/cron/src/Controller/Cron.php
@@ -129,14 +129,12 @@ class Cron
     {
         $configKey = $this->cronconfig->getOptionalString('key', 'secret');
         if ($key !== $configKey) {
-            Logger::error('Cron - Wrong key provided. Cron will not run.');
-            exit;
+            throw new Error\Exception('Cron - Wrong key provided. Cron will not run.');
         }
 
         $cron = new \SimpleSAML\Module\cron\Cron();
         if (!$cron->isValidTag($tag)) {
-            Logger::error('Cron - Illegal tag [' . $tag . '].');
-            exit;
+            throw new Error\Exception(sprintf('Cron - Illegal tag [%s].', $tag));
         }
 
         $httpUtils = new Utils\HTTP();
diff --git a/modules/saml/src/Controller/WebBrowserSingleSignOn.php b/modules/saml/src/Controller/WebBrowserSingleSignOn.php
index 7a996cd4ecbd0f97220b368841be5b9082f116f4..70c447b40eb4226b48c357c8933eee7367938528 100644
--- a/modules/saml/src/Controller/WebBrowserSingleSignOn.php
+++ b/modules/saml/src/Controller/WebBrowserSingleSignOn.php
@@ -137,6 +137,5 @@ class WebBrowserSingleSignOn
         } catch (UnsupportedBindingException $e) {
             throw new Error\Error('SSOPARAMS', $e, 400);
         }
-        Assert::true(false);
     }
 }
diff --git a/src/SimpleSAML/Error/Error.php b/src/SimpleSAML/Error/Error.php
index 3e0791b28eb4f0de22ac13af8a447cc8cd674651..968f1ebdd262c2b2fdbff402f9a5e1fde4d39d87 100644
--- a/src/SimpleSAML/Error/Error.php
+++ b/src/SimpleSAML/Error/Error.php
@@ -247,7 +247,6 @@ class Error extends Exception
         ) {
             // enable error reporting
             $httpUtils = new Utils\HTTP();
-            $baseurl = $httpUtils->getBaseURL();
             $data['errorReportAddress'] = Module::getModuleURL('core/errorReport');
         }
 
diff --git a/tests/modules/core/src/Controller/ErrorReportTest.php b/tests/modules/core/src/Controller/ErrorReportTest.php
index 9c893f0b82d3f8a7a3a41dcbe0b481d459fdd48b..66367f99462d442ca7d57be974ce1d0a8382e313 100644
--- a/tests/modules/core/src/Controller/ErrorReportTest.php
+++ b/tests/modules/core/src/Controller/ErrorReportTest.php
@@ -9,6 +9,7 @@ use SimpleSAML\Configuration;
 use SimpleSAML\Error;
 use SimpleSAML\HTTP\RunnableResponse;
 use SimpleSAML\Module\core\Controller;
+use SimpleSAML\Session;
 use SimpleSAML\XHTML\Template;
 use Symfony\Component\HttpFoundation\Request;
 
@@ -23,6 +24,9 @@ class ErrorReportTest extends TestCase
     /** @var \SimpleSAML\Configuration */
     protected Configuration $config;
 
+    /** @var \SimpleSAML\Session */
+    protected Session $session;
+
 
     /**
      * Set up for each test.
@@ -41,6 +45,8 @@ class ErrorReportTest extends TestCase
         );
 
         Configuration::setPreLoadedConfig($this->config, 'config.php');
+
+        $this->session = Session::getSessionFromRequest();
     }
 
 
@@ -54,7 +60,7 @@ class ErrorReportTest extends TestCase
             'GET',
         );
 
-        $c = new Controller\ErrorReport($this->config);
+        $c = new Controller\ErrorReport($this->config, $this->session);
 
         $response = $c->main($request);
 
@@ -74,7 +80,7 @@ class ErrorReportTest extends TestCase
             ['reportId' => 'abc123'],
         );
 
-        $c = new Controller\ErrorReport($this->config);
+        $c = new Controller\ErrorReport($this->config, $this->session);
 
         $this->expectException(Error\Exception::class);
         $this->expectExceptionMessage('Invalid reportID');
@@ -98,7 +104,7 @@ class ErrorReportTest extends TestCase
             ],
         );
 
-        $c = new Controller\ErrorReport($this->config);
+        $c = new Controller\ErrorReport($this->config, $this->session);
 
         $response = $c->main($request);