 import Foundation
 
 public class BirthdaysManager : ObservableObject {
+  
+  let fileURL: URL
   public var all: [Birthday] {
     didSet {
-      birthdayCounts = all
+      birthdayCountdowns = all
         .map { BirthdayCountdown(birthday: $0) }
         .sorted(by: { $0.remainingDays < $1.remainingDays })
     }
   }
-  @Published public private(set) var birthdayCounts: [BirthdayCountdown]
+  @Published public private(set) var birthdayCountdowns: [BirthdayCountdown]
   
-  public init() {
+  public init(fileURL: URL? = nil) {
+    if let fileURL = fileURL {
+      self.fileURL = fileURL
+    } else {
+      self.fileURL = FileManager.default.birthdaysURL()
+    }
     all = []
-    birthdayCounts = []
+    birthdayCountdowns = []
     
     all = loadBirthdays()
     
-    birthdayCounts = all
+    birthdayCountdowns = all
       .map { BirthdayCountdown(birthday: $0) }
       .sorted(by: { $0.remainingDays < $1.remainingDays })
   }

  func save(birthdays: [Birthday]) {
    do {
      let data = try JSONEncoder().encode(birthdays)
      try data.write(to: FileManager.default.birthdaysURL(), options: .atomic)
    } catch {
      print("error: \(error)")
    }

  
  func loadBirthdays() -> [Birthday] {
    do {
      let data = try Data(contentsOf: fileURL)
      return try JSONDecoder().decode([Birthday].self, from: data)
    } catch {
      return []
