diff --git a/bin/account-manager.pl.in b/bin/account-manager.pl.in
index 1b297f348bb4acc9ee465fb50c2662b164b8a62b..e89f0752e68b0826cede874b35c727ff25a07d38 100755
--- a/bin/account-manager.pl.in
+++ b/bin/account-manager.pl.in
@@ -147,6 +147,7 @@ sub list_accounts {
             IdPAccountManager::Tools::update_ssp_authsources(
                 $configuration->{templates_dir},
                 $configuration->{idp_accounts_file},
+                $configuration->{idp_scope},
                 $accounts
             );
         };
diff --git a/lib/IdPAccountManager/Tools.pm b/lib/IdPAccountManager/Tools.pm
index cf8dc9e2efab76702777474c870ef58f168d6c41..24480188305b13d23aa1da1f87a4a7b48bea574a 100644
--- a/lib/IdPAccountManager/Tools.pm
+++ b/lib/IdPAccountManager/Tools.pm
@@ -6,23 +6,6 @@ use warnings;
 use Digest::SHA;
 use Encode;
 use Template;
-use Template::Stash;
-
-INIT {
-    ## a TT2 virtual method to get a variable type
-    $Template::Stash::LIST_OPS->{isa} = sub {
-        my ($list, $type) = @_;
-
-        return 1 if ($type eq 'ARRAY');
-        return 0;
-    };
-    $Template::Stash::SCALAR_OPS->{isa} = sub {
-        my ($list, $type) = @_;
-
-        return 1 if ($type eq 'SCALAR');
-        return 0;
-    };
-}
 
 # get SHA256 hash for a string
 sub sha256_hash {
@@ -80,14 +63,15 @@ sub generate_password {
 
 ## Updates simpleSamlPhp authsources.php configuration file
 sub update_ssp_authsources {
-    my ($templates_dir, $output, $accounts) = @_;
+    my ($templates_dir, $output, $idp_scope, $accounts) = @_;
 
     my $tt2 = Template->new({
         INCLUDE_PATH => $templates_dir
     });
     my $template = 'accountProfiles/valid-accounts.php.tt2';
     my $data = {
-        accounts => $accounts
+        accounts  => $accounts,
+        idp_scope => $idp_scope
     };
 
     $tt2->process($template, $data, $output) or die $tt2->error();
diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm
index c87f50d0ad13ae681ed0ccd4dc199e56755f2c0f..0ff7dba6d214b90831bb5050757567387f53a112 100755
--- a/lib/IdPAccountManager/WebRequest.pm
+++ b/lib/IdPAccountManager/WebRequest.pm
@@ -489,7 +489,8 @@ sub req_validate_token {
     IdPAccountManager::Tools::update_ssp_authsources(
             $self->{configuration}->{templates_dir},
             $self->{configuration}->{idp_accounts_file},
-            \@accounts
+            $self->{configuration}->{idp_scope},
+            \@accounts,
         );
     };
     if ($EVAL_ERROR) {
diff --git a/templates/accountProfiles/alumni1.tt2 b/templates/accountProfiles/alumni1.tt2
index d89e98747e27649bafa358cbaec01d07e9a413bc..fa143cf7c78ba7afddefb177d261053c3f9b6b42 100644
--- a/templates/accountProfiles/alumni1.tt2
+++ b/templates/accountProfiles/alumni1.tt2
@@ -1,17 +1,14 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'Alumni',
-	'comment' => 'Value "member" is not set for eduPersonAffiliation, contrary to current students.',
-  	'internal_uid' => "user${account_id}",
-	'eduPersonAffiliation' => ['alum'],
-	'eduPersonScopedAffiliation' => ["alum@${conf.idp_scope}"],
-        'displayName' => 'Åsold Wahlstrøm - eduGAIN Access Check account',
-        'cn' => 'Åsold Wahlstrøm - eduGAIN Access Check account',
-        'mail' => "asold.wahlstrom@${conf.idp_scope}",
-        'eduPersonPrincipalName' =>"${account_id}@${conf.idp_scope}",
-        'schacHomeOrganization' => "${conf.idp_scope}",
-        'schacHomeOrganizationType' => 'urn:schac:homeOrganizationType:int:other',
-} %]
-
+        /*
+            profile type: alumni
+            Value "member" is not set for eduPersonAffiliation, contrary to 
+            current students
+        */ 
+        'internal_uid' => 'user[% account.id() %]',
+        'cn'           => 'Åsold Wahlstrøm - eduGAIN Access Check account',
+        'displayName'  => 'Åsold Wahlstrøm - eduGAIN Access Check account',
+        'mail'         => 'asold.wahlstrom@[% idp_scope %]',
+        'eduPersonAffiliation'       => ['alum'],
+        'eduPersonScopedAffiliation' => ['alum@[% idp_scope %]'],
+        'eduPersonPrincipalName'     => '[% account.id() %]@[% idp_scope %]',
+        'schacHomeOrganization'      => '[% idp_scope %]',
+        'schacHomeOrganizationType'  => 'urn:schac:homeOrganizationType:int:other',
diff --git a/templates/accountProfiles/employee1.tt2 b/templates/accountProfiles/employee1.tt2
index 88f328238672305beced955ccf9049e5d49266b1..91f22fe2a4d5a488275cb9ec05e0cddaeb4d14c6 100644
--- a/templates/accountProfiles/employee1.tt2
+++ b/templates/accountProfiles/employee1.tt2
@@ -1,17 +1,16 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'Employee',
-	'comment' => 'There are conflicting definitions of "staff" and "employee" from country to country that make those values particularly unreliable in any international context. However in this example we set both values.',
-  	'internal_uid' => "user${account_id}",
-	'eduPersonAffiliation' => ['member','staff','employee'],
-	'eduPersonScopedAffiliation' => ["member@${conf.idp_scope}","staff@${conf.idp_scope}","employee@${conf.idp_scope}"],
-        'displayName' => 'Linnéa Hsu - eduGAIN Access Check account',
-        'cn' => 'Linnéa Hsu - eduGAIN Access Check account',
-        'mail' => "linnea.hsu@${conf.idp_scope}",
-        'eduPersonPrincipalName' =>"${account_id}@${conf.idp_scope}",
-        'schacHomeOrganization' => "${conf.idp_scope}",
-        'schacHomeOrganizationType' => 'urn:schac:homeOrganizationType:int:other',
-} %]
-
+        /*
+            profile type: employee
+            There are conflicting definitions of "staff" and "employee" from
+            country to country that make those values particularly unreliable
+            in any international context. However in this example we set both
+            values
+        */ 
+        'internal_uid' => 'user[% account.id() %]',
+        'cn'           => 'Linnéa Hsu - eduGAIN Access Check account',
+        'displayName'  => 'Linnéa Hsu - eduGAIN Access Check account',
+        'mail'         => 'linnea.hsu@[% idp_scope %]',
+        'eduPersonAffiliation'       => ['member','staff','employee'],
+        'eduPersonScopedAffiliation' => ['member@[% idp_scope %]','staff@[% idp_scope %]','employee@[% idp_scope %]'],
+        'eduPersonPrincipalName'     => '[% account.id() %]@[% idp_scope %]',
+        'schacHomeOrganization'      => '[% idp_scope %]',
+        'schacHomeOrganizationType'  => 'urn:schac:homeOrganizationType:int:other',
diff --git a/templates/accountProfiles/fullset1.tt2 b/templates/accountProfiles/fullset1.tt2
index 6ddaa4879a0828a4634881c7b079ff7a8b6e046e..b2db8a9ac819c49ebcc85f71ad2b036670b2907d 100644
--- a/templates/accountProfiles/fullset1.tt2
+++ b/templates/accountProfiles/fullset1.tt2
@@ -1,20 +1,16 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'FullSet',
-	'comment' => "This user profile respresents a researcher with all eduGAIN user attributes plus givenName and surname.",
-  	'internal_uid' => "user${account_id}",
-	'eduPersonAffiliation' => ['member', 'faculty'],
-	'eduPersonScopedAffiliation' => ["member@${conf.idp_scope}", "faculty@${conf.idp_scope}"],
-        'displayName' => 'Gundabald Lightfoot - eduGAIN Access Check account',
-        'cn' => 'Gundabald Lightfoot - eduGAIN Access Check account',
-        'givenName' => 'Gundabald',
-        'sn' => 'Lightfoot - eduGAIN Access Check account',
-        'mail' => "gundabald.lightfoot@${conf.idp_scope}",
-        'eduPersonPrincipalName' =>"${account_id}@${conf.idp_scope}",
-        'schacHomeOrganization' => "${conf.idp_scope}",
-        'schacHomeOrganizationType' => 'urn:schac:homeOrganizationType:int:other',
-} %]
-
-
+        /*
+            profile type: full set
+            This user profile respresents a researcher with all eduGAIN user
+            attributes plus givenName and surname.",
+        */
+        'internal_uid' => 'user[% account.id() %]',
+        'cn'           => 'Gundabald Lightfoot - eduGAIN Access Check account',
+        'displayName'  => 'Gundabald Lightfoot - eduGAIN Access Check account',
+        'givenName'    => 'Gundabald',
+        'sn'           => 'Lightfoot - eduGAIN Access Check account',
+        'mail'         => 'gundabald.lightfoot@[% idp_scope %]',
+        'eduPersonAffiliation'       => ['member', 'faculty'],
+        'eduPersonScopedAffiliation' => ['member@[% idp_scope %]', 'faculty@[% idp_scope %]'],
+        'eduPersonPrincipalName'     => '[% account.id() %]@[% idp_scope %]',
+        'schacHomeOrganization'      => '[% idp_scope %]',
+        'schacHomeOrganizationType'  => 'urn:schac:homeOrganizationType:int:other',
diff --git a/templates/accountProfiles/generic1.tt2 b/templates/accountProfiles/generic1.tt2
index ed49adbaf2d62e4670277dded8dd52df5851223a..e37fd5510c42a129b3c7da9a5bc48edcd8a3d235 100644
--- a/templates/accountProfiles/generic1.tt2
+++ b/templates/accountProfiles/generic1.tt2
@@ -1,13 +1,9 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'Generic',
-	'comment' => 'This account provides a limited set of user attributes (eduPersonPrincipalName, mail and displayName).',
-  	'internal_uid' => "user${account_id}",
-        'displayName' => '山崎 弘子樫野 陽子 - eduGAIN Access Check account',
-        'mail' => "forearartian@${conf.idp_scope}",
-        'eduPersonPrincipalName' =>"${account_id}@${conf.idp_scope}",
-} %]
-
-
+        /*
+            profile type: generic
+            This account provides a limited set of user attributes
+            (eduPersonPrincipalName, mail and displayName)
+        */
+        'internal_uid' => 'user[% account.id() %]',
+        'displayName'  => '山崎 弘子樫野 陽子 - eduGAIN Access Check account',
+        'mail'         => 'forearartian@[% idp_scope %]',
+        'eduPersonPrincipalName' => '[% account.id() %]@[% idp_scope %]',
diff --git a/templates/accountProfiles/librarywalkin1.tt2 b/templates/accountProfiles/librarywalkin1.tt2
index 096b1ec3302858bf861f6cd3f1da8818967fb4f3..f84aceaa70ef3d8d7be8c6e29db61fbae5791901 100644
--- a/templates/accountProfiles/librarywalkin1.tt2
+++ b/templates/accountProfiles/librarywalkin1.tt2
@@ -1,18 +1,25 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'Library walk-in',
-	'comment' => 'This term was created to cover the case where physical presence in a library facility grants someone access to electronic resources typically licensed for faculty, staff and students. In recent years the library walk-in provision has been extended to cover other cases such as library users on the campus network, or those using on-campus workstations. Licensed resource providers have often been willing to interpret their contracts with licensees to accept this broader definition of "library-walk-in," though specific terms may vary. For a more direct way of using eduPerson attributes to express library privilege information, see the eduPersonEntitlement value "urn:mace:dir:entitlement:common-lib-terms" as defined in the MACE-Dir Registry of eduPersonEntitlement values <a href="http://middleware.internet2.edu/urn-mace/urn-mace-dir-entitlement.html">http://middleware.internet2.edu/urn-mace/urn-mace-dir-entitlement.html</a>.',
-  	'internal_uid' => "user${account_id}",
-	'eduPersonAffiliation' => ['library-walk-in'],
-	'eduPersonScopedAffiliation' => ["library-walk-in@${conf.idp_scope}"],
-        'displayName' => 'Ramón Núñez - eduGAIN Access Check account',
-        'cn' => 'Ramón Núñez - eduGAIN Access Check account',
-        'mail' => "ramon.nunez@${conf.idp_scope}",
-        'eduPersonPrincipalName' =>"${account_id}@${conf.idp_scope}",
-        'schacHomeOrganization' => "${conf.idp_scope}",
-        'schacHomeOrganizationType' => 'urn:schac:homeOrganizationType:int:other',
-	'eduPersonEntitlement' => 'urn:mace:dir:entitlement:common-lib-terms',
-} %]
-
+        /*
+            profile type: library walk-in
+            This term was created to cover the case where physical presence in
+            a library facility grants someone access to electronic resources
+            typically licensed for faculty, staff and students. In recent years
+            the library walk-in provision has been extended to cover other
+            cases such as library users on the campus network, or those using
+            on-campus workstations.  Licensed resource providers have often
+            been willing to interpret their contracts with licensees to accept
+            this broader definition of "library-walk-in," though specific terms
+            may vary. For a more direct way of using eduPerson attributes to
+            express library privilege information, see the eduPersonEntitlement
+            value "urn:mace:dir:entitlement:common-lib-terms" as defined in the
+            MACE-Dir Registry of eduPersonEntitlement values http://middleware.internet2.edu/urn-mace/urn-mace-dir-entitlement.html
+        */
+        'internal_uid' => 'user[% account.id() %]',
+        'cn'           => 'Ramón Núñez - eduGAIN Access Check account',
+        'displayName'  => 'Ramón Núñez - eduGAIN Access Check account',
+        'mail'         => 'ramon.nunez@[% idp_scope %]',
+        'eduPersonAffiliation'       => ['library-walk-in'],
+        'eduPersonScopedAffiliation' => ['library-walk-in@[% idp_scope %]'],
+        'eduPersonPrincipalName'     => '[% account.id() %]@[% idp_scope %]',
+        'eduPersonEntitlement'       => 'urn:mace:dir:entitlement:common-lib-terms',
+        'schacHomeOrganization'      => '[% idp_scope %]',
+        'schacHomeOrganizationType'  => 'urn:schac:homeOrganizationType:int:other',
diff --git a/templates/accountProfiles/limitedset1.tt2 b/templates/accountProfiles/limitedset1.tt2
index 6beb400f3625004c31333a4b983472d84264eefa..7100ec444c68fa1032b5277c7e893b5a76e43437 100644
--- a/templates/accountProfiles/limitedset1.tt2
+++ b/templates/accountProfiles/limitedset1.tt2
@@ -1,10 +1,5 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'LimitedSet',
-	'comment' => 'This account provides only an eduPersonTargetedID attribute.',
-  	'internal_uid' => "user${account_id}",
-} %]
-
-
+        /*
+            profile type: limited set
+            This account provides only an eduPersonTargetedID attribute
+        */
+        'internal_uid' => 'user[% account.id() %]',
diff --git a/templates/accountProfiles/researcher1.tt2 b/templates/accountProfiles/researcher1.tt2
index f2e57b47a7ee74d7d7e2a3e98adcf4f45edadda3..6322ddd5dd5ce16b20abb3d9f633b20ff2ef7486 100644
--- a/templates/accountProfiles/researcher1.tt2
+++ b/templates/accountProfiles/researcher1.tt2
@@ -1,18 +1,15 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'Researcher',
-	'comment' => "No standard value for eduPersonAffiliation can be used to represent a researcher. Therefore you can't differenciate a teacher from a researcher.",
-  	'internal_uid' => "user${account_id}",
-	'eduPersonAffiliation' => ['member', 'faculty'],
-	'eduPersonScopedAffiliation' => ["member@${conf.idp_scope}", "faculty@${conf.idp_scope}"],
-        'displayName' => 'Stéphane Larivière - eduGAIN Access Check account',
-        'cn' => 'Stéphane Larivière - eduGAIN Access Check account',
-        'mail' => "stephane.lariviere@${conf.idp_scope}",
-        'eduPersonPrincipalName' =>"${account_id}@${conf.idp_scope}",
-        'schacHomeOrganization' => "${conf.idp_scope}",
-        'schacHomeOrganizationType' => 'urn:schac:homeOrganizationType:int:other',
-} %]
-
-
+        /*
+            profile type: researcher
+            No standard value for eduPersonAffiliation can be used to represent
+            a researcher. Therefore you can't differenciate a teacher from a
+            researcher
+        */
+        'internal_uid' => 'user[% account.id() %]',
+        'cn'           => 'Stéphane Larivière - eduGAIN Access Check account',
+        'displayName'  => 'Stéphane Larivière - eduGAIN Access Check account',
+        'mail'         => 'stephane.lariviere@[% idp_scope %]',
+        'eduPersonAffiliation'       => ['member', 'faculty'],
+        'eduPersonScopedAffiliation' => ['member@[% idp_scope %]', 'faculty@[% idp_scope %]'],
+        'eduPersonPrincipalName'     => '[% account.id() %]@[% idp_scope %]',
+        'schacHomeOrganization'      => '[% idp_scope %]',
+        'schacHomeOrganizationType'  => 'urn:schac:homeOrganizationType:int:other',
diff --git a/templates/accountProfiles/student1.tt2 b/templates/accountProfiles/student1.tt2
index 3a6e7c65aaa1dec99992c81434847ef84e1f1a6d..4525c8d1a2c33edaa185ad519037a5aa6e3d322f 100644
--- a/templates/accountProfiles/student1.tt2
+++ b/templates/accountProfiles/student1.tt2
@@ -1,17 +1,14 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'Student',
-	'comment' => 'An active student has both "member" and "student" values set for eduPersonAffiliation.',
-  	'internal_uid' => "user${account_id}",
-	'eduPersonAffiliation' => ['member', 'student'],
-	'eduPersonScopedAffiliation' => ["member@${conf.idp_scope}","student@${conf.idp_scope}"],
-        'displayName' => 'Ciarán MacCárthaigh - eduGAIN Access Check account',
-        'cn' => 'Ciarán MacCárthaigh - eduGAIN Access Check account',
-        'mail' => "ciaran.maccarthaigh@${conf.idp_scope}",
-        'eduPersonPrincipalName' =>"${account_id}@${conf.idp_scope}",
-        'schacHomeOrganization' => "${conf.idp_scope}",
-        'schacHomeOrganizationType' => 'urn:schac:homeOrganizationType:int:other',
-} %]
-
+        /*
+            profile type: student
+            An active student has both "member" and "student" values set for
+            eduPersonAffiliation
+        */
+        'internal_uid' => 'user[% account.id() %]',
+        'cn'           => 'Ciarán MacCárthaigh - eduGAIN Access Check account',
+        'displayName'  => 'Ciarán MacCárthaigh - eduGAIN Access Check account',
+        'mail'         => 'ciaran.maccarthaigh@[% idp_scope %]',
+        'eduPersonAffiliation'       => ['member', 'student'],
+        'eduPersonScopedAffiliation' => ['member@[% idp_scope %]','student@[% idp_scope %]'],
+        'eduPersonPrincipalName'     => '[% account.id() %]@[% idp_scope %]',
+        'schacHomeOrganization'      => '[% idp_scope %]',
+        'schacHomeOrganizationType'  => 'urn:schac:homeOrganizationType:int:other',
diff --git a/templates/accountProfiles/student2.tt2 b/templates/accountProfiles/student2.tt2
index 60bf538cb0463d43c9a5ba049bdb95e97753e27c..5055ef11a352f82a36d6fc637be67f7f5deb02cd 100644
--- a/templates/accountProfiles/student2.tt2
+++ b/templates/accountProfiles/student2.tt2
@@ -1,17 +1,15 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'Student',
-	'comment' => 'A PhD student, having three values set for eduPersonAffiliation: "member" and "student" and "faculty".',
-  	'internal_uid' => "user${account_id}",
-	'eduPersonAffiliation' => ['member', 'student','faculty'],
-	'eduPersonScopedAffiliation' => ["member@${conf.idp_scope}","student@${conf.idp_scope}","faculty@${conf.idp_scope}"],
-        'displayName' => 'Damiën Kuijper - eduGAIN Access Check account',
-        'cn' => 'Damiën Kuijper - eduGAIN Access Check account',
-        'mail' => "damien.kuijper@${conf.idp_scope}",
-        'eduPersonPrincipalName' =>"${account_id}@${conf.idp_scope}",
-        'schacHomeOrganization' => "${conf.idp_scope}",
-        'schacHomeOrganizationType' => 'urn:schac:homeOrganizationType:int:other',
-} %]
+        /*
+            profile type: student
+            A PhD student, having three values set for eduPersonAffiliation:
+            "member" and "student" and "faculty"
+        */
 
+        'internal_uid' => 'user[% account.id() %]',
+        'cn'           => 'Damiën Kuijper - eduGAIN Access Check account',
+        'displayName'  => 'Damiën Kuijper - eduGAIN Access Check account',
+        'mail'         => 'damien.kuijper@[% idp_scope %]',
+        'eduPersonAffiliation'       => ['member', 'student','faculty'],
+        'eduPersonScopedAffiliation' => ['member@[% idp_scope %]','student@[% idp_scope %]','faculty@[% idp_scope %]'],
+        'eduPersonPrincipalName'     => '[% account.id() %]@[% idp_scope %]',
+        'schacHomeOrganization'      => '[% idp_scope %]',
+        'schacHomeOrganizationType'  => 'urn:schac:homeOrganizationType:int:other',
diff --git a/templates/accountProfiles/teacher1.tt2 b/templates/accountProfiles/teacher1.tt2
index 0128501f8bc3c5012c631e248cecdcbfc1ad59d0..97a02feddc4fc5f41a2f3f35f18ed8527d97fcb7 100644
--- a/templates/accountProfiles/teacher1.tt2
+++ b/templates/accountProfiles/teacher1.tt2
@@ -1,18 +1,14 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'Teacher',
-	'comment' => 'An active teacher has both "member" and "faculty" values set for eduPersonAffiliation.',
-  	'internal_uid' => "user${account_id}",
-	'eduPersonAffiliation' => ['member', 'faculty'],
-	'eduPersonScopedAffiliation' => ["member@${conf.idp_scope}", "faculty@${conf.idp_scope}"],
-        'displayName' => 'Peter Müller - eduGAIN Access Check account',
-        'cn' => 'Peter Müller - eduGAIN Access Check account',
-        'mail' => "peter.muller@${conf.idp_scope}",
-        'eduPersonPrincipalName' =>"${account_id}@${conf.idp_scope}",
-        'schacHomeOrganization' => "${conf.idp_scope}",
-        'schacHomeOrganizationType' => 'urn:schac:homeOrganizationType:int:other',
-} %]
-
-
+        /*
+            profile type: teacher
+            An active teacher has both "member" and "faculty" values set for
+            eduPersonAffiliation
+        */
+        'internal_uid' => 'user[% account.id() %]',
+        'cn'           => 'Peter Müller - eduGAIN Access Check account',
+        'displayName'  => 'Peter Müller - eduGAIN Access Check account',
+        'mail'         => 'peter.muller@[% idp_scope %]',
+        'eduPersonAffiliation'       => ['member', 'faculty'],
+        'eduPersonScopedAffiliation' => ['member@[% idp_scope %]', 'faculty@[% idp_scope %]'],
+        'eduPersonPrincipalName'     => '[% account.id() %]@[% idp_scope %]',
+        'schacHomeOrganization'      => '[% idp_scope %]',
+        'schacHomeOrganizationType'  => 'urn:schac:homeOrganizationType:int:other',
diff --git a/templates/accountProfiles/teacher2.tt2 b/templates/accountProfiles/teacher2.tt2
index f7a4807bb3ae38940243e12c16f40126fe5d2134..4fb05e8dc6659d8b6c0aa80ff1a5287555bc688b 100644
--- a/templates/accountProfiles/teacher2.tt2
+++ b/templates/accountProfiles/teacher2.tt2
@@ -1,11 +1,7 @@
-[% account_sp_entityid = account.sp_entityid() %]
-[% account_id = account.id() %]
-
-[% SET account_profile = {
-	'type' => 'Teacher',
-	'comment' => 'This account provides a limited set of user attributes (eduPersonScopedAffiliation and eduPersonTargetedID).',
-  	'internal_uid' => "user${account_id}",
-	'eduPersonScopedAffiliation' => ["member@${conf.idp_scope}", "faculty@${conf.idp_scope}"],
-} %]
-
-
+        /*
+            profile type: teacher
+            This account provides a limited set of user attributes
+            (eduPersonScopedAffiliation and eduPersonTargetedID)
+        */
+        'internal_uid' => 'user[% account.id() %]',
+        'eduPersonScopedAffiliation' => ['member@[% idp_scope %]', 'faculty@[% idp_scope %]'],
diff --git a/templates/accountProfiles/valid-accounts.php.tt2 b/templates/accountProfiles/valid-accounts.php.tt2
index 1c361655368f050d1c9f8550aadbe095646d7472..5074ce965141042e61ee3c4a8404f1a53019a71c 100644
--- a/templates/accountProfiles/valid-accounts.php.tt2
+++ b/templates/accountProfiles/valid-accounts.php.tt2
@@ -1,22 +1,13 @@
 <?php
-// template for a PhP configuration file loaded in simpleSamlPhp authsources.php file
+// PhP configuration file loaded in simpleSamlPhp authsources.php file
 $validTestAccounts = array (
     'authcrypt:Hash',
 
 [% FOREACH account IN accounts %]
-  [% PROCESS "accountProfiles/${account.account_profile()}.tt2" %]
-  'user[% account.id() %]:{SHA256}[% account.user_password_hash() %]=' => array(
-  [% FOREACH attribute IN account_profile.pairs -%]
-   [% NEXT IF attribute.key.match('^(type|comment)$') %]
-   [% IF attribute.value.isa('SCALAR') -%]
-	'[% attribute.key %]' => '[% attribute.value %]',
-   [% ELSE -%]
-	'[% attribute.key %]' => array('[% attribute.value.join("','") %]'),
-   [% END %]
-  [% END %]
-        'associatedSP' => "[% account.sp_entityid() %]",
-
-  ),
+    'user[% account.id() %]:{SHA256}[% account.user_password_hash() %]=' => array(
+[% INCLUDE "accountProfiles/${account.account_profile()}.tt2" -%]
+        'associatedSP'               => '[% account.sp_entityid() %]',
+    ),
 
 [% END %]
 );