             }
             return;
         }
-        
+
         // Merge thread-related context into the main context
         self.managedObjectContext.mergeChangesFromContextDidSaveNotification(notification)
     }
 
-    public func removeDatabase() throws {
+    public func resetDatabase() throws {
+        //TODO: If the persistentStoreCoordinator had been already created, it must also be reset
+        let path = storeURL.path!
+        guard NSFileManager.defaultManager().fileExistsAtPath(path) else { return }
         try NSFileManager.defaultManager().removeItemAtURL(storeURL)
+        try NSFileManager.defaultManager().createFileAtPath(path, contents: nil, attributes: nil)
     }
 }

    }()

    private let modelName: String
    
    public lazy var managedObjectContext: NSManagedObjectContext! = {
        var managedObjectContext = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
        managedObjectContext.persistentStoreCoordinator = self.persistentStoreCoordinator
        return managedObjectContext
    }()
    
    public lazy var managedObjectModel: NSManagedObjectModel = {
        let modelURL = NSBundle.mainBundle().URLForResource(self.modelName, withExtension: "momd")!
        return NSManagedObjectModel(contentsOfURL: modelURL)!
    }()
    
    public lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator! = {
        // Enable for lightweight model migration
        var options = [String: AnyObject]()
        options[NSMigratePersistentStoresAutomaticallyOption] = true
        options[NSInferMappingModelAutomaticallyOption] = true
        
        let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)

        var failureReason = "There was an error creating or loading the application's saved data."

            NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)")
            abort()
        }

        return coordinator
    }()

    private lazy var storeURL: NSURL = self.applicationDocumentsDirectory().URLByAppendingPathComponent(self.modelName + ".sqlite")

    private init(modelName: String) {
        self.modelName = modelName
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "managedObjectContextDidSaveNotification:", name: NSManagedObjectContextDidSaveNotification, object: nil)
    }

    private func applicationDocumentsDirectory() -> NSURL! {
        let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
        return urls[urls.count - 1]
    }

    //MARK: Support for managed object context access from different threads

    func currentContext() -> NSManagedObjectContext! {
        if NSThread.isMainThread() {
            return self.managedObjectContext
