   }
   
   func testThatRouteHearbeatScenarioIsCorrect() throws {
-    // arrange
-    let beat = 1
-    let heartbeat = Heartbeat(beat: beat)
-    let json = try heartbeat.makeJSON()
-    let reqBody = try Body(json)
-    let req = Request(method: .post, uri: "/heartbeat", headers: ["Content-Type": "application/json"], body: reqBody)
     
-    // act & assert
-    try drop
-      .testResponse(to: req)
-      .assertStatus(is: .ok)
-      .assertJSON("beat", equals: beat)
+    func makePostRequestForHeartbeat(with beat: Int) throws {
+      // arrange
+      let heartbeat = Heartbeat(beat: beat)
+      let json = try heartbeat.makeJSON()
+      let reqBody = try Body(json)
+      let req = Request(method: .post, uri: "/heartbeat", headers: ["Content-Type": "application/json"], body: reqBody)
+      // act & assert
+      try drop
+        .testResponse(to: req)
+        .assertStatus(is: .ok)
+        .assertJSON("beat", equals: beat)
+      try drop
+        .testResponse(to: .get, at: "heartbeat")
+        .assertStatus(is: .ok)
+        .assertJSON("beat", equals: beat)
+    }
     
-    try drop
-      .testResponse(to: .get, at: "heartbeat")
-      .assertStatus(is: .ok)
-      .assertJSON("beat", equals: beat)
-    
-    let beat2 = 2
-    let heartbeat2 = Heartbeat(beat: beat2)
-    let json2 = try heartbeat2.makeJSON()
-    let reqBody2 = try Body(json2)
-    let req2 = Request(method: .post, uri: "/heartbeat", headers: ["Content-Type": "application/json"], body: reqBody2)
-    
-    // act & assert
-    try drop
-      .testResponse(to: req2)
-      .assertStatus(is: .ok)
-      .assertJSON("beat", equals: beat2)
-    
-    try drop
-      .testResponse(to: .get, at: "heartbeat")
-      .assertStatus(is: .ok)
-      .assertJSON("beat", equals: beat2)
-    
+    try makePostRequestForHeartbeat(with: 1)
+    try makePostRequestForHeartbeat(with: 2)
+    try makePostRequestForHeartbeat(with: 1)
+    try makePostRequestForHeartbeat(with: 2)
+  
   }
   
-  
+  // MARK: - Helper functions & extensions
   func setBeat(to value: Int) throws -> ResponseRepresentable {
     let req = Request.makeTest(method: .post)
     req.json =  try JSON(node: ["beat":value])

    return res
  }
  
}



  
  func testThatRouteGetCurrentValueIfBeatTableIsNotEmpty() throws {
    // arange
    try cleanHeartbeatTable()
    let beat = Int.randomValue()
    _ = try setBeat(to: beat)
    // act & assert
    try drop
