diff --git a/src/server.c b/src/server.c
index 388dd8fb5..6dc99eee3 100644
--- a/src/server.c
+++ b/src/server.c
@@ -6932,7 +6932,6 @@ struct serverTest {
     {"ziplist", ziplistTest},
     {"quicklist", quicklistTest},
     {"zipmap", zipmapTest},
-    {"sha1test", sha1Test},
     {"endianconv", endianconvTest},
     {"zmalloc", zmalloc_test},
     {"dict", dictTest},
diff --git a/src/sha1.c b/src/sha1.c
index 3a722933f..67253c2ea 100644
--- a/src/sha1.c
+++ b/src/sha1.c
@@ -207,33 +207,3 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
     memset(&finalcount, '\0', sizeof(finalcount));
 }
 /* ================ end of sha1.c ================ */
-
-#ifdef SERVER_TEST
-#define BUFSIZE 4096
-
-#define UNUSED(x) (void)(x)
-int sha1Test(int argc, char **argv, int flags)
-{
-    SHA1_CTX ctx;
-    unsigned char hash[20], buf[BUFSIZE];
-    int i;
-
-    UNUSED(argc);
-    UNUSED(argv);
-    UNUSED(flags);
-
-    for(i=0;i<BUFSIZE;i++)
-        buf[i] = i;
-
-    SHA1Init(&ctx);
-    for(i=0;i<1000;i++)
-        SHA1Update(&ctx, buf, BUFSIZE);
-    SHA1Final(hash, &ctx);
-
-    printf("SHA1=");
-    for(i=0;i<20;i++)
-        printf("%02x", hash[i]);
-    printf("\n");
-    return 0;
-}
-#endif
diff --git a/src/sha1.h b/src/sha1.h
index 176511796..60751ed88 100644
--- a/src/sha1.h
+++ b/src/sha1.h
@@ -21,7 +21,4 @@ void SHA1Init(SHA1_CTX* context);
 __attribute__((noinline)) void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
 void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
 
-#ifdef SERVER_TEST
-int sha1Test(int argc, char **argv, int flags);
-#endif
 #endif
diff --git a/src/unit/test_files.h b/src/unit/test_files.h
index 01f61bac1..1127efd5a 100644
--- a/src/unit/test_files.h
+++ b/src/unit/test_files.h
@@ -22,6 +22,7 @@ int test_kvstoreIteratorRemoveAllKeysDeleteEmptyDict(int argc, char **argv, int
 int test_kvstoreDictIteratorRemoveAllKeysNoDeleteEmptyDict(int argc, char **argv, int flags);
 int test_kvstoreDictIteratorRemoveAllKeysDeleteEmptyDict(int argc, char **argv, int flags);
 int test_sds(int argc, char **argv, int flags);
+int test_sha1(int argc, char **argv, int flags);
 int test_string2ll(int argc, char **argv, int flags);
 int test_string2l(int argc, char **argv, int flags);
 int test_ll2string(int argc, char **argv, int flags);
@@ -34,6 +35,7 @@ unitTest __test_crc64combine_c[] = {{"test_crc64combine", test_crc64combine}, {N
 unitTest __test_intset_c[] = {{"test_intsetValueEncodings", test_intsetValueEncodings}, {"test_intsetBasicAdding", test_intsetBasicAdding}, {"test_intsetLargeNumberRandomAdd", test_intsetLargeNumberRandomAdd}, {"test_intsetUpgradeFromint16Toint32", test_intsetUpgradeFromint16Toint32}, {"test_intsetUpgradeFromint16Toint64", test_intsetUpgradeFromint16Toint64}, {"test_intsetUpgradeFromint32Toint64", test_intsetUpgradeFromint32Toint64}, {"test_intsetStressLookups", test_intsetStressLookups}, {"test_intsetStressAddDelete", test_intsetStressAddDelete}, {NULL, NULL}};
 unitTest __test_kvstore_c[] = {{"test_kvstoreAdd16Keys", test_kvstoreAdd16Keys}, {"test_kvstoreIteratorRemoveAllKeysNoDeleteEmptyDict", test_kvstoreIteratorRemoveAllKeysNoDeleteEmptyDict}, {"test_kvstoreIteratorRemoveAllKeysDeleteEmptyDict", test_kvstoreIteratorRemoveAllKeysDeleteEmptyDict}, {"test_kvstoreDictIteratorRemoveAllKeysNoDeleteEmptyDict", test_kvstoreDictIteratorRemoveAllKeysNoDeleteEmptyDict}, {"test_kvstoreDictIteratorRemoveAllKeysDeleteEmptyDict", test_kvstoreDictIteratorRemoveAllKeysDeleteEmptyDict}, {NULL, NULL}};
 unitTest __test_sds_c[] = {{"test_sds", test_sds}, {NULL, NULL}};
+unitTest __test_sha1_c[] = {{"test_sha1", test_sha1}, {NULL, NULL}};
 unitTest __test_util_c[] = {{"test_string2ll", test_string2ll}, {"test_string2l", test_string2l}, {"test_ll2string", test_ll2string}, {"test_ld2string", test_ld2string}, {"test_fixedpoint_d2string", test_fixedpoint_d2string}, {"test_reclaimFilePageCache", test_reclaimFilePageCache}, {NULL, NULL}};
 
 struct unitTestSuite {
@@ -45,5 +47,6 @@ struct unitTestSuite {
     {"test_intset.c", __test_intset_c},
     {"test_kvstore.c", __test_kvstore_c},
     {"test_sds.c", __test_sds_c},
+    {"test_sha1.c", __test_sha1_c},
     {"test_util.c", __test_util_c},
 };
diff --git a/src/unit/test_sha1.c b/src/unit/test_sha1.c
new file mode 100644
index 000000000..68f18825a
--- /dev/null
+++ b/src/unit/test_sha1.c
@@ -0,0 +1,27 @@
+#include "../sha1.c"
+#include "test_help.h"
+
+#define BUFSIZE 4096
+
+int test_sha1(int argc, char **argv, int flags) {
+    SHA1_CTX ctx;
+    unsigned char hash[20], buf[BUFSIZE];
+    unsigned char expected[20] = {0x15, 0xdd, 0x99, 0xa1, 0x99, 0x1e, 0x0b, 0x38,
+        0x26, 0xfe, 0xde, 0x3d, 0xef, 0xfc, 0x1f, 0xeb, 0xa4, 0x22, 0x78, 0xe6};
+    int i;
+
+    UNUSED(argc);
+    UNUSED(argv);
+    UNUSED(flags);
+
+    for(i=0;i<BUFSIZE;i++)
+        buf[i] = i;
+
+    SHA1Init(&ctx);
+    for(i=0;i<1000;i++)
+        SHA1Update(&ctx, buf, BUFSIZE);
+    SHA1Final(hash, &ctx);
+
+    TEST_ASSERT(memcmp(hash, expected, 20) == 0);
+    return 0;
+}