diff --git a/Makefile b/Makefile
index 75a48f46f24c6830d4700ff99db3bfceca249895..3499f12abaeac702d215d74b0056d8fb8218677c 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ all:
 # To build with Lua, download and unzip Lua 5.2.1 source code into the
 # mongoose directory, and then add $(LUA_FLAGS) to CFLAGS below
 LUA         = lua-5.2.1/src
-LUA_FLAGS   = -DUSE_LUA -I$(LUA) -L$(LUA) -llua -lm
+LUA_FLAGS   = -I$(LUA) -L$(LUA) -llua -lm
 
 CFLAGS      = -std=c99 -O2 -W -Wall -pedantic -pthread $(COPT)
 LIB         = lib$(PROG).so$(MONGOOSE_LIB_SUFFIX)
@@ -49,8 +49,8 @@ cocoa:
 	$(CC) mongoose.c main.c -DUSE_COCOA $(CFLAGS) -framework Cocoa -ObjC -arch i386 -arch x86_64 -o Mongoose
 	V=`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' mongoose.c`; DIR=dmg/Mongoose.app && rm -rf $$DIR && mkdir -p $$DIR/Contents/{MacOS,Resources} && install -m 644 build/mongoose_*.png $$DIR/Contents/Resources/ && install -m 644 build/Info.plist $$DIR/Contents/ && install -m 755 Mongoose $$DIR/Contents/MacOS/ && ln -fs /Applications dmg/ ; hdiutil create Mongoose_$$V.dmg -volname "Mongoose $$V" -srcfolder dmg -ov #; rm -rf dmg
 
-unix_unit_test:
-	$(CC) -I. test/unit_test.c -o unit_test $(CFLAGS)
+unix_unit_test: $(LUA_OBJECTS)
+	$(CC) test/unit_test.c -o unit_test -I. $(LUA_FLAGS) $(CFLAGS) -g -O0
 	./unit_test
 
 ##########################################################################
@@ -66,7 +66,7 @@ CYA   = e:/cyassl-2.0.0rc2
 #DBG  = /Zi /DDEBUG /Od
 DBG   = /DNDEBUG /O1
 CL    = $(MSVC)/bin/cl /MD /TC /nologo $(DBG) /Gz /W3 /DNO_SSL_DL \
-        /I$(MSVC)/include /DUSE_LUA /I$(LUA) /I. /GA
+        /I$(MSVC)/include /I$(LUA) /I. /GA
 MSLIB = /link /incremental:no /libpath:$(MSVC)/lib /machine:IX86 \
         user32.lib shell32.lib comdlg32.lib ws2_32.lib advapi32.lib \
         cyassl.lib lua.lib
@@ -116,7 +116,7 @@ windows_unit_test: cyassl.lib lua.lib
 
 windows: cyassl.lib lua.lib
 	$(MSVC)/bin/rc build\res.rc
-	$(CL) main.c mongoose.c $(MSLIB) build\res.res \
+	$(CL) main.c mongoose.c /DUSE_LUA $(MSLIB) build\res.res \
 	/out:$(PROG).exe /subsystem:windows
 #	$(CL) mongoose.c /GD $(LINK) /DLL /DEF:build\dll.def /out:$(PROG).dll