diff --git a/common/cpp/include/common/error.h b/common/cpp/include/common/error.h
index 863b87dafad91f0fb3d2f3488147a0c84650e3d8..12488250f0c878fb05463c40bdfe84276efac1b2 100644
--- a/common/cpp/include/common/error.h
+++ b/common/cpp/include/common/error.h
@@ -10,7 +10,7 @@ namespace asapo {
 enum class ErrorType {
     kUnknownError,
 
-    kHidraError,
+    kAsapoError,
     kHttpError,
     kIOError,
     kReceiverError,
@@ -46,8 +46,8 @@ class ErrorTemplateInterface {
   public:
     virtual ErrorType GetErrorType() const noexcept = 0;
     virtual Error Generate() const noexcept = 0;
+    virtual Error Generate(const std::string& suffix) const noexcept = 0;
     virtual std::string Text() const noexcept = 0;
-
     virtual inline bool operator == (const Error& rhs) const {
         return rhs != nullptr &&
                GetErrorType() == rhs->GetErrorType();
@@ -79,7 +79,7 @@ static inline std::ostream& operator<<(std::ostream& os, const Error& err) {
 class SimpleError: public ErrorInterface {
   private:
     std::string error_;
-    ErrorType error_type_ = ErrorType::kHidraError;
+    ErrorType error_type_ = ErrorType::kAsapoError;
   public:
     explicit SimpleError(std::string error): error_{std::move(error)} {
 
@@ -109,7 +109,7 @@ class SimpleError: public ErrorInterface {
 class SimpleErrorTemplate : public ErrorTemplateInterface {
   protected:
     std::string error_;
-    ErrorType error_type_ = ErrorType::kHidraError;
+    ErrorType error_type_ = ErrorType::kAsapoError;
   public:
     explicit SimpleErrorTemplate(std::string error): error_{std::move(error)} {
 
@@ -130,6 +130,11 @@ class SimpleErrorTemplate : public ErrorTemplateInterface {
     inline Error Generate() const noexcept override {
         return Error(new SimpleError{error_, error_type_});
     }
+
+    inline Error Generate(const std::string& suffix) const noexcept override {
+        return Error(new SimpleError{error_ + " :" + suffix, error_type_});
+    }
+
 };
 
 static inline std::ostream& operator<<(std::ostream& os, const SimpleErrorTemplate& err) {
@@ -157,45 +162,44 @@ auto const kEndOfFile = SimpleErrorTemplate {
 
 template <typename ServiceErrorType, ErrorType MainErrorType>
 class ServiceError : public SimpleError {
- private:
-  ServiceErrorType error_type_;
- public:
-  ServiceError(const std::string& error, ServiceErrorType error_type) : SimpleError(error, MainErrorType) {
-      error_type_ = error_type;
-  }
-  ServiceErrorType GetServiceErrorType() const noexcept {
-      return error_type_;
-  }
+  private:
+    ServiceErrorType error_type_;
+  public:
+    ServiceError(const std::string& error, ServiceErrorType error_type) : SimpleError(error, MainErrorType) {
+        error_type_ = error_type;
+    }
+    ServiceErrorType GetServiceErrorType() const noexcept {
+        return error_type_;
+    }
 };
 
 template <typename ServiceErrorType, ErrorType MainErrorType>
 class ServiceErrorTemplate : public SimpleErrorTemplate {
- protected:
-  ServiceErrorType error_type_;
- public:
-  ServiceErrorTemplate(const std::string& error, ServiceErrorType error_type) : SimpleErrorTemplate(error,
-                                                                                                    MainErrorType) {
-      error_type_ = error_type;
-  }
-
-  inline ServiceErrorType GetServiceErrorType() const noexcept {
-      return error_type_;
-  }
-
-  inline Error Generate() const noexcept override {
-      auto err = new ServiceError<ServiceErrorType, MainErrorType>(error_, error_type_);
-      return Error(err);
-  }
-
-  inline Error Generate(const std::string& prefix) const noexcept {
-      auto err = new ServiceError<ServiceErrorType, MainErrorType>(prefix + " :" + error_, error_type_);
-      return Error(err);
-  }
-
-  inline bool operator==(const Error& rhs) const override {
-      return SimpleErrorTemplate::operator==(rhs)
-          && GetServiceErrorType() == ((ServiceError<ServiceErrorType, MainErrorType>*) rhs.get())->GetServiceErrorType();
-  }
+  protected:
+    ServiceErrorType error_type_;
+  public:
+    ServiceErrorTemplate(const std::string& error, ServiceErrorType error_type) : SimpleErrorTemplate(error,
+                MainErrorType) {
+        error_type_ = error_type;
+    }
+
+    inline ServiceErrorType GetServiceErrorType() const noexcept {
+        return error_type_;
+    }
+
+    inline Error Generate() const noexcept override {
+        auto err = new ServiceError<ServiceErrorType, MainErrorType>(error_, error_type_);
+        return Error(err);
+    }
+
+    inline Error Generate(const std::string& suffix) const noexcept override {
+        return Error(new ServiceError<ServiceErrorType, MainErrorType>(error_ + " :" + suffix, error_type_));
+    }
+
+    inline bool operator==(const Error& rhs) const override {
+        return SimpleErrorTemplate::operator==(rhs)
+               && GetServiceErrorType() == ((ServiceError<ServiceErrorType, MainErrorType>*) rhs.get())->GetServiceErrorType();
+    }
 };
 
 }
diff --git a/common/cpp/include/common/io_error.h b/common/cpp/include/common/io_error.h
index f7cfc46df6448791ebb7f3ba9ff12dc8970afbce..a04af80203e35cd82cd9f13fe64803775141fc7c 100644
--- a/common/cpp/include/common/io_error.h
+++ b/common/cpp/include/common/io_error.h
@@ -30,45 +30,8 @@ enum class IOErrorType {
 
 };
 
-class IOError : public SimpleError {
-  private:
-    IOErrorType io_error_type_;
-  public:
-    IOError(const std::string& error, IOErrorType io_error_type) : SimpleError(error, ErrorType::kIOError) {
-        io_error_type_ = io_error_type;
-    }
-
-    IOErrorType GetIOErrorType() const noexcept {
-        return io_error_type_;
-    }
-};
-
-class IOErrorTemplate : public SimpleErrorTemplate {
-  protected:
-    IOErrorType io_error_type_;
-  public:
-    IOErrorTemplate(const std::string& error, IOErrorType io_error_type) : SimpleErrorTemplate(error, ErrorType::kIOError) {
-        io_error_type_ = io_error_type;
-    }
-
-    inline IOErrorType GetIOErrorType() const noexcept {
-        return io_error_type_;
-    }
-
-    inline Error Generate() const noexcept override {
-        return Error(new IOError(error_, io_error_type_));
-    }
-
-    inline bool operator == (const Error& rhs) const override {
-        return SimpleErrorTemplate::operator==(rhs)
-               && GetIOErrorType() == ((IOError*)rhs.get())->GetIOErrorType();
-    }
-};
-
-static inline std::ostream& operator<<(std::ostream& os, const IOErrorTemplate& err) {
-    return os << err.Text();
-}
-
+using IOError = ServiceError<IOErrorType, ErrorType::kIOError>;
+using IOErrorTemplate = ServiceErrorTemplate<IOErrorType, ErrorType::kIOError>;
 
 namespace IOErrorTemplates {
 auto const kUnknownIOError = IOErrorTemplate {
diff --git a/producer/api/include/producer/producer_error.h b/producer/api/include/producer/producer_error.h
index 5ed0cdc1e8c9f4cbde03d4fde62af41a041b2927..87fc9206b9a8aafecc912a5beb84f16dedbb27c9 100644
--- a/producer/api/include/producer/producer_error.h
+++ b/producer/api/include/producer/producer_error.h
@@ -19,48 +19,7 @@ enum class ProducerErrorType {
     kRequestPoolIsFull
 };
 
-//TODO Make a marco to create error class and error template class
-class ProducerError : public SimpleError {
-  private:
-    ProducerErrorType receiver_error_type_;
-  public:
-    ProducerError(const std::string& error, ProducerErrorType receiver_error_type) : SimpleError(error,
-                ErrorType::kProducerError) {
-        receiver_error_type_ = receiver_error_type;
-    }
-
-    ProducerErrorType GetProducerErrorType() const noexcept {
-        return receiver_error_type_;
-    }
-};
-
-class ProducerErrorTemplate : public SimpleErrorTemplate {
-  protected:
-    ProducerErrorType receiver_error_type_;
-  public:
-    ProducerErrorTemplate(const std::string& error, ProducerErrorType receiver_error_type) : SimpleErrorTemplate(error,
-                ErrorType::kProducerError) {
-        receiver_error_type_ = receiver_error_type;
-    }
-
-    inline ProducerErrorType GetProducerErrorType() const noexcept {
-        return receiver_error_type_;
-    }
-
-    inline Error Generate() const noexcept override {
-        return Error(new ProducerError(error_, receiver_error_type_));
-    }
-
-    inline bool operator==(const Error& rhs) const override {
-        return SimpleErrorTemplate::operator==(rhs)
-               && GetProducerErrorType() == ((ProducerError*) rhs.get())->GetProducerErrorType();
-    }
-};
-
-static inline std::ostream& operator<<(std::ostream& os, const ProducerErrorTemplate& err) {
-    return os << err.Text();
-}
-
+using ProducerErrorTemplate = ServiceErrorTemplate<ProducerErrorType, ErrorType::kProducerError>;
 
 namespace ProducerErrorTemplates {
 auto const kAlreadyConnected = ProducerErrorTemplate {
diff --git a/producer/event_monitor_producer/src/event_monitor_error.h b/producer/event_monitor_producer/src/event_monitor_error.h
index 0c4c566d282c40a1e96b480f7fde15ae950830f7..87aafe82f736102a41a00b402017605b20d68dd6 100644
--- a/producer/event_monitor_producer/src/event_monitor_error.h
+++ b/producer/event_monitor_producer/src/event_monitor_error.h
@@ -10,52 +10,7 @@ enum class EventMonitorErrorType {
     kSystemError
 };
 
-class EventMonitorError : public SimpleError {
-  private:
-    EventMonitorErrorType error_type_;
-  public:
-    EventMonitorError(const std::string& error, EventMonitorErrorType error_type) : SimpleError(error,
-                ErrorType::kHidraError) {
-        error_type_ = error_type;
-    }
-
-    EventMonitorErrorType GetEventMonitorErrorType() const noexcept {
-        return error_type_;
-    }
-};
-
-class EventMonitorErrorTemplate : public SimpleErrorTemplate {
-  protected:
-    EventMonitorErrorType error_type_;
-  public:
-    EventMonitorErrorTemplate(const std::string& error, EventMonitorErrorType error_type) : SimpleErrorTemplate(error,
-                ErrorType::kHidraError) {
-        error_type_ = error_type;
-    }
-
-    inline EventMonitorErrorType GetEventMonitorErrorType() const noexcept {
-        return error_type_;
-    }
-
-    inline Error Generate(std::string sub_error) const noexcept {
-        return Error(new EventMonitorError(error_ + ": " + sub_error, error_type_));
-    }
-
-
-    inline Error Generate() const noexcept override {
-        return Error(new EventMonitorError(error_, error_type_));
-    }
-
-    inline bool operator==(const Error& rhs) const override {
-        return SimpleErrorTemplate::operator==(rhs)
-               && GetEventMonitorErrorType() == ((EventMonitorError*) rhs.get())->GetEventMonitorErrorType();
-    }
-};
-
-static inline std::ostream& operator<<(std::ostream& os, const EventMonitorErrorTemplate& err) {
-    return os << err.Text();
-}
-
+using EventMonitorErrorTemplate = ServiceErrorTemplate<EventMonitorErrorType, ErrorType::kAsapoError>;
 
 namespace EventMonitorErrorTemplates {
 auto const kNoNewEvent = EventMonitorErrorTemplate {
diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt
index 3bccb108760827e87ad3b553927a8662b4962470..fcc419fd88bfda278722f05e88f94c8963c8995b 100644
--- a/receiver/CMakeLists.txt
+++ b/receiver/CMakeLists.txt
@@ -71,4 +71,4 @@ gtest(${TARGET_NAME} "${TEST_SOURCE_FILES}" "${TEST_LIBRARIES}" ${CMAKE_CURRENT_
 
 set(TEST_SOURCE_FILES_RDS
         unittests/receiver_data_server/test_receiver_data_server.cpp)
-gtest(${TARGET_NAME}_RDS "${TEST_SOURCE_FILES_RDS}" "${TEST_LIBRARIES}")
+gtest(${TARGET_NAME}_RDS "${TEST_SOURCE_FILES_RDS}" "${TEST_LIBRARIES}" ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h)
diff --git a/receiver/src/receiver_error.h b/receiver/src/receiver_error.h
index c90a0d55531c754800df049b26dadd91e60979ea..795c13f7b16cf9bb0fa0967409f43abe7566214d 100644
--- a/receiver/src/receiver_error.h
+++ b/receiver/src/receiver_error.h
@@ -11,58 +11,18 @@ enum class ReceiverErrorType {
     kAuthorizationFailure
 };
 
-//TODO Make a marco to create error class and error template class
-class ReceiverError : public SimpleError {
-  private:
-    ReceiverErrorType receiver_error_type_;
-  public:
-    ReceiverError(const std::string& error, ReceiverErrorType receiver_error_type) : SimpleError(error,
-                ErrorType::kReceiverError) {
-        receiver_error_type_ = receiver_error_type;
-    }
-
-    ReceiverErrorType GetReceiverErrorType() const noexcept {
-        return receiver_error_type_;
-    }
-};
-
-class ReceiverErrorTemplate : public SimpleErrorTemplate {
-  protected:
-    ReceiverErrorType receiver_error_type_;
-  public:
-    ReceiverErrorTemplate(const std::string& error, ReceiverErrorType receiver_error_type) : SimpleErrorTemplate(error,
-                ErrorType::kReceiverError) {
-        receiver_error_type_ = receiver_error_type;
-    }
-
-    inline ReceiverErrorType GetReceiverErrorType() const noexcept {
-        return receiver_error_type_;
-    }
-
-    inline Error Generate() const noexcept override {
-        return Error(new ReceiverError(error_, receiver_error_type_));
-    }
-
-    inline bool operator==(const Error& rhs) const override {
-        return SimpleErrorTemplate::operator==(rhs)
-               && GetReceiverErrorType() == ((ReceiverError*) rhs.get())->GetReceiverErrorType();
-    }
-};
-
-static inline std::ostream& operator<<(std::ostream& os, const ReceiverErrorTemplate& err) {
-    return os << err.Text();
-}
+using ReceiverErrorTemplate = ServiceErrorTemplate<ReceiverErrorType, ErrorType::kReceiverError>;
 
 
 namespace ReceiverErrorTemplates {
-auto const kInvalidOpCode = ReceiverErrorTemplate {
+auto const kInvalidOpCode = ReceiverErrorTemplate{
     "Invalid Opcode", ReceiverErrorType::kInvalidOpCode
 };
-auto const kBadRequest = ReceiverErrorTemplate {
+auto const kBadRequest = ReceiverErrorTemplate{
     "Bad request", ReceiverErrorType::kBadRequest
 };
 
-auto const kAuthorizationFailure = ReceiverErrorTemplate {
+auto const kAuthorizationFailure = ReceiverErrorTemplate{
     "authorization failure", ReceiverErrorType::kAuthorizationFailure
 };