diff --git a/core/Controllers/ResController.php b/core/Controllers/ResController.php
index 0dd3a637e9e4fb884da4cd0e72489e97ec4b9638..3b437330d4bae99ebfe13301e7011ea8556c026c 100755
--- a/core/Controllers/ResController.php
+++ b/core/Controllers/ResController.php
@@ -24,7 +24,7 @@ use Core\Models\DocserverTypeModel;
 use Core\Models\UserModel;
 use Core\Models\ResModel;
 use Notes\Models\NoteModel;
-use Entities\Models\EntitiesModel;
+use Entities\Models\EntityModel;
 use Core\Controllers\DocserverController;
 use Core\Controllers\DocserverToolsController;
 
@@ -580,7 +580,7 @@ class ResController
         $fileFormat = $aArgs['fileFormat'];
 
         $userModel = new UserModel();
-        $entityModel = new \Entities\Models\EntitiesModel();
+        $entityModel = new \Entities\Models\EntityModel();
 
         $countD = count($data);
         for ($i = 0; $i < $countD; $i++) {
diff --git a/core/Models/ResModelAbstract.php b/core/Models/ResModelAbstract.php
index 530b70f524ed7e7243c1f78bb3f93a173bade271..5cec09e5fe4abf0669ea9ac17d865cec6c827c71 100755
--- a/core/Models/ResModelAbstract.php
+++ b/core/Models/ResModelAbstract.php
@@ -64,7 +64,6 @@ class ResModelAbstract
         $aReturn = DatabaseModel::select([
             'select'    => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
             'table'     => [$table],
-            'data'      => [$aArgs['resId']],
             'order_by'  => ['res_id desc'],
             'limit'     => 1,
         ]);
diff --git a/core/Test/DocserverControllerTest.php b/core/Test/DocserverControllerTest.php
index d1c38a880430155b569d4265c2eb2880864cf659..4f17b98b27fe7f7607acec0b3f9206b9d0292e1e 100755
--- a/core/Test/DocserverControllerTest.php
+++ b/core/Test/DocserverControllerTest.php
@@ -9,9 +9,9 @@ namespace MaarchTest;
 *
 */
 
-require_once __DIR__.'/define.php';
+use PHPUnit\Framework\TestCase;
 
-class DocserverControllerTest extends \PHPUnit_Framework_TestCase
+class DocserverControllerTest extends TestCase
 {
     public function testGetList()
     {
diff --git a/core/Test/DocserverToolsControllerTest.php b/core/Test/DocserverToolsControllerTest.php
index 41bd681198d461ca79942eb5a26a8cc0e3d1e673..4505917121510540b916861805e731adb10d5d4a 100755
--- a/core/Test/DocserverToolsControllerTest.php
+++ b/core/Test/DocserverToolsControllerTest.php
@@ -9,9 +9,9 @@ namespace MaarchTest;
 *
 */
 
-require_once __DIR__.'/define.php';
+use PHPUnit\Framework\TestCase;
 
-class DocserverToolsControllerTest extends \PHPUnit_Framework_TestCase
+class DocserverToolsControllerTest extends TestCase
 {
     public function testSetRights()
     {
diff --git a/core/Test/DocserverTypeControllerTest.php b/core/Test/DocserverTypeControllerTest.php
index 3eb826418265a56638ae1a834a695cdc63547198..5da82ffc4cd4885a159d18c48f7b0132734745f2 100755
--- a/core/Test/DocserverTypeControllerTest.php
+++ b/core/Test/DocserverTypeControllerTest.php
@@ -1,7 +1,5 @@
 <?php
 
-namespace MaarchTest;
-
 /**
 * Copyright Maarch since 2008 under licence GPLv3.
 * See LICENCE.txt file at the root folder for more details.
@@ -9,9 +7,10 @@ namespace MaarchTest;
 *
 */
 
-require_once __DIR__.'/define.php';
+namespace MaarchTest;
+use PHPUnit\Framework\TestCase;
 
-class DocserverTypeControllerTest extends \PHPUnit_Framework_TestCase
+class DocserverTypeControllerTest extends TestCase
 {
     public function testGetList()
     {
diff --git a/core/Test/ParametersControllerTest.php b/core/Test/ParametersControllerTest.php
index ab829c7d213218240a8b5561f0b493d3b8422428..7ccf394ccf0e0bbe1c9e9222dc7620444a96fb37 100755
--- a/core/Test/ParametersControllerTest.php
+++ b/core/Test/ParametersControllerTest.php
@@ -8,10 +8,9 @@
 */
 
 namespace MaarchTest;
+use PHPUnit\Framework\TestCase;
 
-require_once __DIR__.'/define.php';
-
-class ParametersControllerTest extends \PHPUnit_Framework_TestCase
+class ParametersControllerTest extends TestCase
 {
     public function testCreate()
     {
diff --git a/core/Test/ReportControllerTest.php b/core/Test/ReportControllerTest.php
index 4e650404bec3e09d959f86b8ffbe7c591726c34c..74c8cab8bf3476f87a9b29d91f0418fbf8befb04 100755
--- a/core/Test/ReportControllerTest.php
+++ b/core/Test/ReportControllerTest.php
@@ -9,9 +9,9 @@ namespace MaarchTest;
 *
 */
 
-require_once __DIR__.'/define.php';
+use PHPUnit\Framework\TestCase;
 
-class ReportsTest extends \PHPUnit_Framework_TestCase
+class ReportsTest extends TestCase
 {
     public function testGetList()
     {
diff --git a/core/Test/ResControllerTest.php b/core/Test/ResControllerTest.php
index 4544a6535e15a6b96fd1f91ec884929c51d70b53..f9cc616d6b69972577cea81a4b1ae8a4f9b9de2b 100755
--- a/core/Test/ResControllerTest.php
+++ b/core/Test/ResControllerTest.php
@@ -9,9 +9,10 @@ namespace MaarchTest;
 *
 */
 
-require_once __DIR__.'/define.php';
+namespace MaarchTest;
+use PHPUnit\Framework\TestCase;
 
-class ResControllerTest extends \PHPUnit_Framework_TestCase
+class ResControllerTest extends TestCase
 {
 
     public function testPrepareStorage()
@@ -131,7 +132,7 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase
             ]
         );
 
-        $resId = \Core\Models\ResModel::getLastId(['select' => 'res_id']);
+        $resId = \Core\Models\ResModel::getLastId(['select' => ['res_id']]);
 
         $aArgs = [
             'id'=> $resId[0]['res_id']
@@ -233,7 +234,7 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase
     {
         $action = new \Core\Controllers\ResController();
 
-        $resId = \Core\Models\ResModel::getLastId(['select' => 'res_id']);
+        $resId = \Core\Models\ResModel::getLastId(['select' => ['res_id']]);
 
         $aArgs = [
             'id'=> $resId[0]['res_id']
@@ -265,7 +266,7 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase
             )
         );
 
-        $resId = \Core\Models\ResModel::getLastId(['select' => 'res_id']);
+        $resId = \Core\Models\ResModel::getLastId(['select' => ['res_id']]);
 
         $aArgs = [
             'table'         => 'res_letterbox',
@@ -276,8 +277,8 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase
         $request = \Slim\Http\Request::createFromEnvironment($environment);
         $response = new \Slim\Http\Response();
         $response = $action->update($request, $response, $aArgs);
-        //print_r($response);exit;
-        $this->assertGreaterThan(1, json_decode($response->getBody())[0]);
+        //print_r(json_decode($response->getBody())[0]->res_id);exit;
+        $this->assertGreaterThan(1, json_decode($response->getBody())[0]->res_id);
     }
 
     public function testUpdateResource()
@@ -295,7 +296,7 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase
             )
         );
 
-        $resId = \Core\Models\ResModel::getLastId(['select' => 'res_id']);
+        $resId = \Core\Models\ResModel::getLastId(['select' => ['res_id']]);
 
         $aArgs = [
             'table'         => 'res_letterbox',
diff --git a/core/Test/ResExtControllerTest.php b/core/Test/ResExtControllerTest.php
index 762772b01d3a0d82ce2d5f7568137e0fc43e3cdf..51a8866bf9b5a87f7a2e63df1679831938e38256 100755
--- a/core/Test/ResExtControllerTest.php
+++ b/core/Test/ResExtControllerTest.php
@@ -9,9 +9,9 @@ namespace MaarchTest;
 *
 */
 
-require_once __DIR__.'/define.php';
+use PHPUnit\Framework\TestCase;
 
-class ResExtControllerTest extends \PHPUnit_Framework_TestCase
+class ResExtControllerTest extends TestCase
 {
     public function testCreate()
     {
@@ -125,7 +125,7 @@ class ResExtControllerTest extends \PHPUnit_Framework_TestCase
             ]
         );
 
-        $resId = \Core\Models\ResExtModel::getLastId(['select' => 'res_id']);
+        $resId = \Core\Models\ResExtModel::getLastId(['select' => ['res_id']]);
 
         $aArgs = [
             'id'=> $resId[0]['res_id']
@@ -325,7 +325,7 @@ class ResExtControllerTest extends \PHPUnit_Framework_TestCase
     {
         $action = new \Core\Controllers\ResExtController();
 
-        $resId = \Core\Models\ResExtModel::getLastId(['select' => 'res_id']);
+        $resId = \Core\Models\ResExtModel::getLastId(['select' => ['res_id']]);
 
         $aArgs = [
             'id'=> $resId[0]['res_id']
diff --git a/modules/entities/Controllers/EntitiesController.php b/modules/entities/Controllers/EntitiesController.php
index 714898023dd5735666e4622e6221c5c0c4d0afaf..153a19c78c9e9b526c8a201d148c97d853763b1f 100755
--- a/modules/entities/Controllers/EntitiesController.php
+++ b/modules/entities/Controllers/EntitiesController.php
@@ -18,7 +18,7 @@ namespace Core\Controllers;
 use Psr\Http\Message\RequestInterface;
 use Psr\Http\Message\ResponseInterface;
 use Respect\Validation\Validator;
-use Entities\Models\EntitiesModel;
+use Entities\Models\EntityModel;
 
 class EntitiesController
 {
diff --git a/modules/entities/Models/EntityModelAbstract.php b/modules/entities/Models/EntityModelAbstract.php
index 1fef4a5a1490a06a4d4bae5a74f6f567ae2789b2..360ff3d3c86b9014c1c2e6f7be1b2377b3f8e2e9 100755
--- a/modules/entities/Models/EntityModelAbstract.php
+++ b/modules/entities/Models/EntityModelAbstract.php
@@ -21,6 +21,22 @@ use Core\Models\ValidatorModel;
 
 class EntityModelAbstract
 {
+    public static function getByEmail(array $aArgs = [])
+    {
+        ValidatorModel::notEmpty($aArgs, ['email']);
+        ValidatorModel::stringType($aArgs, ['email']);
+
+        $aReturn = DatabaseModel::select([
+            'select'    => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
+            'table'     => ['entities'],
+            'where'     => ['email = ? and enabled = ?'],
+            'data'      => [$aArgs['email'], 'Y'],
+            'limit'     => 1,
+        ]);
+
+        return $aReturn;
+    }
+    
     public static function get(array $aArgs = [])
     {
         $aEntities = DatabaseModel::select([
diff --git a/phpunit.xml b/phpunit.xml
index 22fa45e88933d3fb8b600d581eb22b7d8daabe39..1e934824f1d49fcfa5c48b2e478dcede567c1cac 100755
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -3,9 +3,12 @@
     <testsuites>
         <testsuite name="Maarch Core Test Suite">
             <!--directory>core/Test</directory-->
-            <file>core/Test/UserControllerTest.php</file>
-            <file>core/Test/StatusControllerTest.php</file>
+            <!--file>core/Test/ActionControllerTest.php</file-->
             <file>core/Test/PriorityControllerTest.php</file>
+            <file>core/Test/ResControllerTest.php</file>
+            <file>core/Test/ResExtControllerTest.php</file>
+            <file>core/Test/StatusControllerTest.php</file>
+            <file>core/Test/UserControllerTest.php</file>
         </testsuite>
     </testsuites>
     <filter>