diff --git a/lib/IdPAccountManager/Tools.pm b/lib/IdPAccountManager/Tools.pm
index 089b76e5483181e64278e06c3f995fcdc16f8103..568e9ae7412080ce9483b5014f86682fe7bb4da7 100644
--- a/lib/IdPAccountManager/Tools.pm
+++ b/lib/IdPAccountManager/Tools.pm
@@ -1,5 +1,8 @@
 package IdPAccountManager::Tools;
 
+use strict;
+use warnings;
+
 use Digest::SHA;
 use Encode;
 use Template;
@@ -145,7 +148,7 @@ sub mail_notice {
     }
 
     $logger->tracef(
-        sprintf('(template=%s, to=%s)', $in{template}, $mail_data->{to})
+        sprintf('(template=%s, to=%s)', $args{template}, $mail_data->{to})
     );
 
     open SENDMAIL,
@@ -154,7 +157,7 @@ sub mail_notice {
       . " $notice_email";
 
     my $tt2 = Template->new({
-        FILTERS      => { qencode => [ \qencode, 0 ] },
+        FILTERS      => { qencode => [ \&qencode, 0 ] },
         INCLUDE_PATH => $args{templates_dir}
     });
     unless ($tt2->process($tt2_file, $mail_data, \*SENDMAIL)) {