diff --git a/README.mkd b/README.mkd
--- a/README.mkd
+++ b/README.mkd
@@ -9,7 +9,8 @@
 Compatibility
 --------------
 
-network-info has been tested and is known to work on Ubuntu 10.04 and
-Windows XP. It probably works on other flavours of Linux and Windows as
-well. I haven't tried to get it working on BSD or Mac OS X yet but it
-should be quite similar if not the same as the code for Linux.
+network-info has been tested and is known to work on Ubuntu 10.10, Mac
+OS X 10.6.4 and Windows XP. It probably works on other flavours of
+Linux, OS X and Windows as well. I haven't tried to get it working on
+BSD yet, but it should be quite similar if not the same as the code for
+OS X.
diff --git a/cbits/network-linux.c b/cbits/network-linux.c
deleted file mode 100644
--- a/cbits/network-linux.c
+++ /dev/null
@@ -1,79 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <wchar.h>
-
-#include <ifaddrs.h>
-#include <netdb.h>
-#include <netpacket/packet.h>
-
-#include "network.h"
-#include "common.h"
-
-
-void maccopy(unsigned char *dst, struct sockaddr *addr)
-{
-    /* TODO check that sll_halen is equal to 6 (MAC_SIZE) */
-    memcpy(dst, ((struct sockaddr_ll *)addr)->sll_addr, MAC_SIZE);
-}
-
-struct network_interface *add_interface(struct network_interface *ns, const wchar_t *name, int max_ns)
-{
-    int i;
-    for (i = 0; i < max_ns; i++) {
-        if (wcsempty(ns[i].name)) {
-            wszcopy(ns[i].name, name, NAME_SIZE);
-            return &ns[i];
-        } else if (wcscmp(ns[i].name, name) == 0) {
-            return &ns[i];
-        }
-    }
-    return NULL;
-}
-
-int count_interfaces(struct network_interface *ns, int max_ns)
-{
-    int i;
-    for (i = 0; i < max_ns; i++) {
-        if (wcsempty(ns[i].name)) {
-            break;
-        }
-    }
-    return i;
-}
-
-int c_get_network_interfaces(struct network_interface *ns, int max_ns)
-{
-    struct network_interface *n;
-    struct ifaddrs *ifaddr, *ifa;
-    struct sockaddr *addr;
-    wchar_t name[NAME_SIZE];
-    int family, error;
-   
-    error = getifaddrs(&ifaddr);
-    if (error != 0) {
-        perror("getifaddrs");
-        return 0;
-    }
-
-    memset(ns, 0, sizeof(struct network_interface) * max_ns);
-
-    for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
-        mbswszcopy(name, ifa->ifa_name, NAME_SIZE);
-        addr = ifa->ifa_addr;
-        family = addr->sa_family;
-
-        n = add_interface(ns, name, max_ns);
-
-        if (family == AF_INET) {
-            ipv4copy(&n->ip_address, addr);
-        } else if (family == AF_INET6) {
-            ipv6copy(&n->ip6_address, addr);
-        } else if (family == AF_PACKET) {
-            maccopy(n->mac_address, addr);
-        }
-    }
-
-    freeifaddrs(ifaddr);
-    return count_interfaces(ns, max_ns);
-}
diff --git a/cbits/network-unix.c b/cbits/network-unix.c
new file mode 100644
--- /dev/null
+++ b/cbits/network-unix.c
@@ -0,0 +1,91 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+#include <ifaddrs.h>
+#include <netdb.h>
+
+#ifdef __linux__
+#   include <netpacket/packet.h>
+#else
+#   include <net/if_dl.h>
+#   define AF_PACKET AF_LINK
+#endif
+
+#include "network.h"
+#include "common.h"
+
+
+void maccopy(unsigned char *dst, struct sockaddr *addr)
+{
+#ifdef __linux__
+    /* TODO check that sll_halen is equal to 6 (MAC_SIZE) */
+    memcpy(dst, ((struct sockaddr_ll *)addr)->sll_addr, MAC_SIZE);
+#else
+    /* TODO check that sdl_alen is equal to 6 (MAC_SIZE) */
+    struct sockaddr_dl *sdl = (struct sockaddr_dl *)addr;
+    memcpy(dst, sdl->sdl_data + sdl->sdl_nlen, MAC_SIZE);
+#endif
+}
+
+struct network_interface *add_interface(struct network_interface *ns, const wchar_t *name, int max_ns)
+{
+    int i;
+    for (i = 0; i < max_ns; i++) {
+        if (wcsempty(ns[i].name)) {
+            wszcopy(ns[i].name, name, NAME_SIZE);
+            return &ns[i];
+        } else if (wcscmp(ns[i].name, name) == 0) {
+            return &ns[i];
+        }
+    }
+    return NULL;
+}
+
+int count_interfaces(struct network_interface *ns, int max_ns)
+{
+    int i;
+    for (i = 0; i < max_ns; i++) {
+        if (wcsempty(ns[i].name)) {
+            break;
+        }
+    }
+    return i;
+}
+
+int c_get_network_interfaces(struct network_interface *ns, int max_ns)
+{
+    struct network_interface *n;
+    struct ifaddrs *ifaddr, *ifa;
+    struct sockaddr *addr;
+    wchar_t name[NAME_SIZE];
+    int family, error;
+   
+    error = getifaddrs(&ifaddr);
+    if (error != 0) {
+        perror("getifaddrs");
+        return 0;
+    }
+
+    memset(ns, 0, sizeof(struct network_interface) * max_ns);
+
+    for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+        mbswszcopy(name, ifa->ifa_name, NAME_SIZE);
+        addr = ifa->ifa_addr;
+        family = addr->sa_family;
+
+        n = add_interface(ns, name, max_ns);
+
+        if (family == AF_INET) {
+            ipv4copy(&n->ip_address, addr);
+        } else if (family == AF_INET6) {
+            ipv6copy(&n->ip6_address, addr);
+        } else if (family == AF_PACKET) {
+            maccopy(n->mac_address, addr);
+        }
+    }
+
+    freeifaddrs(ifaddr);
+    return count_interfaces(ns, max_ns);
+}
diff --git a/network-info.cabal b/network-info.cabal
--- a/network-info.cabal
+++ b/network-info.cabal
@@ -1,37 +1,35 @@
-Name:                network-info
-version:             0.1.0.1
-synopsis:            Access the local computer's basic network configuration
-description:         This library provides simple read-only access to the local computer's
-                     networking configuration. It is currently capable of getting a list of
-                     all the network interfaces and their respective IPv4, IPv6 and MAC
-                     addresses.
-                     .
-                     The executable 'test-network-info' will only be built if the flag 'test'
-                     has been set.
-homepage:            http://github.com/jystic/network-info
-license:             BSD3
-license-file:        LICENSE
-author:              Jacob Stanley
-maintainer:          jacob@stanley.io
-category:            Network
-build-type:          Simple
-cabal-version:       >=1.8.0.4
+name:           network-info
+version:        0.2
+synopsis:       Access the local computer's basic network configuration
+description:    This library provides simple read-only access to the local computer's
+                networking configuration. It is currently capable of getting a list of
+                all the network interfaces and their respective IPv4, IPv6 and MAC
+                addresses.
+                .
+                network-info has been tested and is known to work on Ubuntu 10.10, Mac
+                OS X 10.6.4 and Windows XP.
+homepage:       http://github.com/jystic/network-info
+license:        BSD3
+license-file:   LICENSE
+author:         Jacob Stanley
+maintainer:     jacob@stanley.io
+category:       Network
+build-type:     Simple
+cabal-version:  >= 1.6
 
 extra-source-files:
   cbits/common.h,
   cbits/network.h,
-  README.mkd,
-  run-tests.sh,
-  run-tests.bat
+  test/src/Main.hs,
+  test/network-info-test.cabal,
+  test/run-tests.bat,
+  test/run-tests.sh,
+  README.mkd
 
 source-repository head
   type:     git
   location: git://github.com/jystic/network-info.git
 
-Flag test
-  description: Build test program
-  default:     False
-
 Library
   hs-source-dirs: src
   include-dirs: cbits
@@ -42,22 +40,11 @@
   build-depends:
     base == 4.*
 
-  if os(linux)
-    c-sources: cbits/network-linux.c
+  if os(linux) || os(darwin)
+    c-sources: cbits/network-unix.c
   else
     if os(windows)
       c-sources: cbits/network-windows.c
       extra-libraries: iphlpapi
     else
       buildable: False
-
-Executable test-network-info
-  hs-source-dirs: test
-  main-is: Main.hs
-
-  if flag(test)
-    build-depends:
-      base == 4.*,
-      network-info
-  else
-    buildable: False
diff --git a/run-tests.bat b/run-tests.bat
deleted file mode 100644
--- a/run-tests.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-@echo off
-cabal configure -ftest && cabal build && dist\build\test-network-info\test-network-info.exe
diff --git a/run-tests.sh b/run-tests.sh
deleted file mode 100644
--- a/run-tests.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-cabal configure -ftest && cabal build && dist/build/test-network-info/test-network-info
diff --git a/test/Main.hs b/test/Main.hs
deleted file mode 100644
--- a/test/Main.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-module Main (main) where
-
-import Network.Info
-
-main = do
-    ns <- getNetworkInterfaces
-    mapM (putStrLn . showInterface) ns
-
-showInterface :: NetworkInterface -> String
-showInterface n = name n ++ "\n"
-               ++ "IPv4 Address: " ++ show (ipv4 n) ++ "\n"
-               ++ "IPv6 Address: " ++ show (ipv6 n) ++ "\n"
-               ++ "MAC Address:  " ++ show (mac n) ++ "\n"
diff --git a/test/network-info-test.cabal b/test/network-info-test.cabal
new file mode 100644
--- /dev/null
+++ b/test/network-info-test.cabal
@@ -0,0 +1,24 @@
+name:           network-info-test
+version:        0.1
+build-type:     Simple
+cabal-version:  >= 1.6
+
+Executable network-info-test
+  hs-source-dirs: ../src src
+  include-dirs: ../cbits
+  cc-options: -Wall -Werror
+
+  main-is: Main.hs
+  other-modules: Network.Info
+
+  build-depends:
+    base == 4.*
+
+  if os(linux) || os(darwin)
+    c-sources: ../cbits/network-unix.c
+  else
+    if os(windows)
+      c-sources: ../cbits/network-windows.c
+      extra-libraries: iphlpapi
+    else
+      buildable: False
diff --git a/test/run-tests.bat b/test/run-tests.bat
new file mode 100644
--- /dev/null
+++ b/test/run-tests.bat
@@ -0,0 +1,2 @@
+@echo off
+cabal configure && cabal build && .\dist\build\network-info-test\network-info-test.exe
diff --git a/test/run-tests.sh b/test/run-tests.sh
new file mode 100644
--- /dev/null
+++ b/test/run-tests.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+TESTDIR="$(dirname -- "${0}")"
+cd $TESTDIR
+
+cabal configure && cabal build && ./dist/build/network-info-test/network-info-test
diff --git a/test/src/Main.hs b/test/src/Main.hs
new file mode 100644
--- /dev/null
+++ b/test/src/Main.hs
@@ -0,0 +1,13 @@
+module Main (main) where
+
+import Network.Info
+
+main = do
+    ns <- getNetworkInterfaces
+    mapM (putStrLn . showInterface) ns
+
+showInterface :: NetworkInterface -> String
+showInterface n = name n ++ "\n"
+               ++ "IPv4 Address: " ++ show (ipv4 n) ++ "\n"
+               ++ "IPv6 Address: " ++ show (ipv6 n) ++ "\n"
+               ++ "MAC Address:  " ++ show (mac n) ++ "\n"
