diff --git a/lib/gpio.js b/lib/gpio.js
index <HASH>..<HASH> 100644
--- a/lib/gpio.js
+++ b/lib/gpio.js
@@ -55,7 +55,7 @@ var _export = function(n, fn) {
 	}
 };
 var _testwrite = function(file, fn) {
-	fs.open(file, function(err, fd) {
+	fs.open(file, 'w', function(err, fd) {
 		if (err) {
 			fn(false, err);
 			return;
@@ -117,7 +117,7 @@ var GPIO = function(headerNum, opts) {
 		var attempts = 0;
 		var makeAttempt = function() {
 			attempts += 1;
-			_testwrite(this.PATH.DIRECTION, function(success, err){
+			_testwrite(self.PATH.DIRECTION, function(success, err){
 				if (success) {
 					onSuccess();
 				} else {
Open with 'w' mode and fix reference to this.