diff --git a/testaddsel.cpp b/testaddsel.cpp
deleted file mode 100644
index 9269afb..0000000
--- a/testaddsel.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "sensorhandler.hpp"
-
-#include <errno.h>
-#include <limits.h>
-#include <mapper.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <systemd/sd-bus.h>
-
-extern void send_esel(uint16_t recordid);
-
-sd_bus* bus = NULL;
-
-// Use a lookup table to find the interface name of a specific sensor
-// This will be used until an alternative is found.  this is the first
-// step for mapping IPMI
-int find_openbmc_path(const uint8_t num, dbus_interface_t* interface)
-{
-    const char* objname = "/org/openbmc/managers/System";
-
-    char *str1, *str2, *str3;
-    sd_bus_error error = SD_BUS_ERROR_NULL;
-    sd_bus_message *reply = NULL, *m = NULL;
-    int r;
-    char* busname = NULL;
-
-    r = mapper_get_service(bus, objname, &busname);
-    if (r < 0)
-    {
-        log<level::ERR>("Failed to get busname", entry("BUS=%s", objname),
-                        entry("ERRNO=0x%X", -r));
-        goto final;
-    }
-
-    r = sd_bus_message_new_method_call(bus, &m, busname, objname, busname,
-                                       "getObjectFromByteId");
-    if (r < 0)
-    {
-        log<level::ERR>("Failed to create a method call",
-                        entry("ERRNO=0x%X", -r));
-    }
-
-    r = sd_bus_message_append(m, "sy", type, num);
-    if (r < 0)
-    {
-        log<level::ERR>("Failed to create a input parameter",
-                        entry("ERRNO=0x%X", -r));
-    }
-
-    // Call the IPMI responder on the bus so the message can be sent to the CEC
-    r = sd_bus_call(bus, m, 0, &error, &reply);
-    if (r < 0)
-    {
-        log<level::ERR>("Failed to call the method", entry("ERRNO=0x%X", -r));
-        goto final;
-    }
-
-    r = sd_bus_message_read(reply, "(sss)", &str1, &str2, &str3);
-    if (r < 0)
-    {
-        log<level::ERR>("Failed to get a response", entry("ERRNO=0x%X", -r));
-        goto final;
-    }
-
-    strncpy(interface->bus, str1, MAX_DBUS_PATH);
-    strncpy(interface->path, str2, MAX_DBUS_PATH);
-    strncpy(interface->interface, str3, MAX_DBUS_PATH);
-
-    interface->sensornumber = num;
-
-final:
-
-    sd_bus_error_free(&error);
-    sd_bus_message_unref(m);
-    free(busname);
-
-    return r;
-}
-
-int main(int argc, char* argv[])
-{
-    int base;
-    char *endptr, *str;
-    long val;
-    uint16_t num;
-    int r;
-
-    if (argc < 2)
-    {
-        fprintf(stderr, "Usage: %s sensornumber\n", argv[0]);
-        return -1;
-    }
-
-    str = argv[1];
-    base = (argc > 2) ? atoi(argv[2]) : 10;
-
-    val = strtol(str, &endptr, base);
-
-    num = (uint16_t)val;
-
-    /* Connect to system bus */
-    r = sd_bus_open_system(&bus);
-    if (r < 0)
-    {
-        log<level::ERR>("Failed to connect to system bus",
-                        entry("ERRNO=0x%X", -r));
-        goto finish;
-    }
-
-    send_esel(num);
-
-finish:
-    sd_bus_unref(bus);
-
-    return 0;
-}
diff --git a/testit.cpp b/testit.cpp
deleted file mode 100644
index 0a703ab..0000000
--- a/testit.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-
-unsigned char g_sensortype[][2] = {
-    {0xC3, 0x01}, {0x07, 0x02}, {0x0F, 0x05}, {0x0c, 0x1F}, {0xFF, 0xff}};
-
-uint8_t find_type_for_sensor_number(uint8_t sensor_number)
-{
-    int i = 0;
-    uint8_t rc;
-
-    while (g_sensortype[i][0] != 0xff)
-    {
-        if (g_sensortype[i][1] == sensor_number)
-        {
-            break;
-        }
-        else
-        {
-            i++;
-        }
-    }
-
-    rc = g_sensortype[i][0];
-
-    if (rc == 0xFF)
-    {
-        rc = 0;
-    }
-    return rc;
-}
-
-char g_results_method[64];
-char g_results_value[64];
-
-int set_sensor_dbus_state_s(unsigned char number, const char* member,
-                            const char* value)
-{
-    strcpy(g_results_method, member);
-    strcpy(g_results_value, value);
-
-    return 0;
-}
-
-int set_sensor_dbus_state_y(unsigned char number, const char* member,
-                            uint8_t value)
-{
-    char val[2];
-
-    snprintf(val, 2, "%d", value);
-
-    strcpy(g_results_method, member);
-    strcpy(g_results_value, val);
-
-    return 0;
-}
-
-extern int updateSensorRecordFromSSRAESC(const void* record);
-
-// DIMM Present
-uint8_t testrec_sensor1[] = {0x1F, 0xa9, 0x00, 0x40, 0x00,
-                             0x00, 0x00, 0x00, 0x00, 0x00};
-
-// DIMM Not present
-uint8_t testrec_sensor2[] = {0x1F, 0xa9, 0x00, 0x00, 0x00,
-                             0x40, 0x00, 0x00, 0x00, 0x00};
-
-// DIMM Not present
-uint8_t testrec_procfailed[] = {0x02, 0xa9, 0x00, 0x00, 0x00,
-                                0x00, 0x01, 0x00, 0x00, 0x00};
-
-// Virtual Sensor 5, setting a Value of 0h
-uint8_t testrec_bootprogress[] = {0x05, 0xa9, 0x00, 0x04, 0x00,
-                                  0x00, 0x00, 0x00, 0x0E, 0x00};
-
-// Virtual Sensor setting a boot count
-uint8_t testrec_bootcount[] = {0x01, 0x09, 0x00, 0x03, 0x00,
-                               0x00, 0x00, 0x00, 0x00, 0x00};
-
-// Invalid sensor number
-uint8_t testrec_invalidnumber[] = {0x35, 0xa9, 0x00, 0x04, 0x00,
-                                   0x00, 0x00, 0x00, 0x03, 0x00};
-
-int check_results(int rc, const char* method, const char* value)
-{
-    if (strcmp(g_results_method, method))
-    {
-        log<level::ERR>("Method Failed", entry("EXPECT=%s", method),
-                        entry("GOT=%s", g_results_method));
-        return -1;
-    }
-    if (strcmp(g_results_value, value))
-    {
-        log<level::ERR>("Value failed", entry("EXPECT=%s", value),
-                        entry("GOT=%s", g_results_method));
-        return -2;
-    }
-
-    return 0;
-}
-
-void testprep(void)
-{
-    memset(g_results_method, 0, sizeof(g_results_method));
-    memset(g_results_value, 0, sizeof(g_results_value));
-}
-
-int main()
-{
-    testprep();
-    check_results(updateSensorRecordFromSSRAESC(testrec_bootprogress),
-                  "setValue", "FW Progress, Docking station attachment");
-    testprep();
-    check_results(updateSensorRecordFromSSRAESC(testrec_sensor1), "setPresent",
-                  "True");
-    testprep();
-    check_results(updateSensorRecordFromSSRAESC(testrec_sensor2), "setPresent",
-                  "False");
-    testprep();
-    check_results(updateSensorRecordFromSSRAESC(testrec_procfailed), "setFault",
-                  "False");
-    testprep();
-    check_results(updateSensorRecordFromSSRAESC(testrec_bootcount), "setValue",
-                  "3");
-    testprep();
-    check_results(updateSensorRecordFromSSRAESC(testrec_invalidnumber), "", "");
-
-    return 0;
-}
