diff --git a/bin/account-manager-client.pl b/bin/account-manager-client.pl
index fb8c0c050e84dbfc59b5451a6032b7c9dfa666cc..9590cd57533dc637800204b80668ed94f1ee920a 100755
--- a/bin/account-manager-client.pl
+++ b/bin/account-manager-client.pl
@@ -19,7 +19,7 @@ use IdPAccountManager::AuthenticationToken;
 my %options;
 unless (&GetOptions(\%options, 'help', 'add_test_account', 'account_profile=s', 'sp_entityid=s', 'list_test_accounts', 'parse_federation_metadata',
                     'list_service_providers','list_authentication_tokens', 'get_authentication_token', 'add_authentication_token','email_address=s',
-                    'token=s','send_notice')) {
+                    'token=s','send_notice','filter_expired','delete')) {
     die "Unknown options.";
 }
 
@@ -62,16 +62,30 @@ if ($options{'add_test_account'}) {
         push @{$args{'query'}}, 'account_profile' => $options{'account_profile'};
     }
     
+    if ($options{'filter_expired'}) {
+        push @{$args{'query'}}, 'expiration_date' => {lt => time};
+    }
     
     my $all = IdPAccountManager::TestAccount::list_test_accounts(%args);
     
     if ($#{$all} < 0) {
-        printf "No test account in DB\n";
+        printf "No matching test account in DB\n";
     }
     
     foreach my $test_account (@$all) {
         $test_account->print();
+        $test_account->delete || die if ($options{'delete'});        
     }
+    
+    if ($options{'delete'}) {
+        printf "%d accounts removed\n", $#{$all}+1;
+
+        ## Update simpleSamlPhp configuration file
+        printf "Update simpleSamlPhp configuration file...\n";
+        IdPAccountManager::Tools::update_ssp_authsources();
+    }
+
+    
 }elsif ($options{'parse_federation_metadata'}) {
     my $federation_metadata = new IdPAccountManager::SAMLMetadata;
     unless ($federation_metadata->load(federation_metadata_file_path => $Conf::global{'federation_metadata_file_path'})) {
@@ -222,6 +236,14 @@ Adds a new test account.
 
 List all test accounts. Criterias can be added to filter test accounts.
 
+=item C<account-manager-client.pl --list_test_accounts --filter_expired>
+
+List all expired test accounts.
+
+=item C<account-manager-client.pl --list_test_accounts --filter_expired --delete>
+
+Remove all expired test accounts from DB.
+
 =item C<account-manager-client.pl --parse_federation_metadata>
 
 Parses the SAML metadata file, as defined by the C<federation_metadata_file_path> configuration parameter.
diff --git a/bin/expire-test-accounts.pl b/bin/expire-test-accounts.pl
deleted file mode 100755
index cba95192a37380d26da2b6c47a456e6b19ad9707..0000000000000000000000000000000000000000
--- a/bin/expire-test-accounts.pl
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/perl
-
-## 09/09/2014, Olivier Salaün
-## Command-line script to remove expired test accounts
-## The script also updates the simpleSamlPhp config file
-
-use strict;
-use utf8;
-use lib "/opt/testidp/IdPAccountManager/lib";
-use lib "/opt/testidp/IdPAccountManager/conf";
-
-use Getopt::Long;
-use POSIX;
-
-use IdPAccountManager::TestAccount;
-
-my %options;
-unless (&GetOptions(\%options, 'help', 'list_only')) {
-    die "Unknown options.";
-}
-
-if ($options{'help'}) {
-    printf "$0 --list_only\n";
-}
-            
-if ($options {'list_only'}) {
-    my $all = IdPAccountManager::TestAccount::list_test_accounts('query' => ['expiration_date' => {lt => time}]);
-    
-    foreach my $test_account (@$all) {
-        $test_account->print();
-    }
-    
-}else {
-    ## Remove expired test accounts
-    my $all = IdPAccountManager::TestAccount::list_test_accounts('query' => ['expiration_date' => {lt => time}]);
-    
-    printf "Removing expired test accounts...\n";
-    foreach my $test_account (@$all) {
-        $test_account->print();
-        $test_account->delete || die;
-    }
-    printf "%d accounts removed\n", $#{$all}+1;
-
-    #&IdPAccountManager::Tools::dump_var(\%Conf::global, 0, \*STDOUT);
-
-    ## Update simpleSamlPhp configuration file
-    printf "Update simpleSamlPhp configuration file...\n";
-
-    IdPAccountManager::Tools::update_ssp_authsources();
-}
-
-