      - Throws: Will throw upon failure to create directory
      - Returns: Unique path to which save the given event
      */
-    private func writePath(_ event: Event) throws -> String? {
-        guard let sentryDir = directory() else { return nil }
-        let date = NSDate().timeIntervalSince1970 + 60 + Double(arc4random_uniform(10) + 1)
+    private func writeEvent(_ event: Event, to path: String?) throws -> String? {
+        guard let path = path else { return nil }
+        let date = Date().timeIntervalSince1970 + 60 + Double(arc4random_uniform(10) + 1)
         
         #if swift(>=3.0)
-            try FileManager.default.createDirectory(atPath: sentryDir, withIntermediateDirectories: true, attributes: nil)
-            return (sentryDir as NSString).appendingPathComponent("\(date)-\(event.eventID)")
+            try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil)
+            return (path as NSString).appendingPathComponent("\(date)-\(event.eventID)")
         #else
-            try NSFileManager.defaultManager().createDirectoryAtPath(sentryDir, withIntermediateDirectories: true, attributes: nil)
-            return (sentryDir as NSString).stringByAppendingPathComponent("\(date)-\(event.eventID)")
+            try NSFileManager.defaultManager().createDirectoryAtPath(path, withIntermediateDirectories: true, attributes: nil)
+            return (path as NSString).stringByAppendingPathComponent("\(date)-\(event.eventID)")
         #endif
     }
     

        return []
    }
    
    // MARK: - Private Helpers
    
    /// Path of directory to which events will be saved in offline mode
    private func directory() -> String? {
        #if swift(>=3.0)
            guard let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first else { return nil }
        #else
            guard let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first else { return nil }
        #endif
        
        guard let serverURLString = dsn.url.absoluteString else {
            return nil

    internal func saveEvent(_ event: Event) {
        do {
            // Gets write path and serialized string for event
            guard let path = try writeEvent(event, to: appendSentryDirToPath(cachesDirectory())),
                let text = try serializeEvent(event) else {
                    return
            }
            
            // Writes the event data to file
            #if swift(>=3.0)
