diff --git a/tests/testthat/test-Zalpha_BetaCDF.R b/tests/testthat/test-Zalpha_BetaCDF.R
index 81f6b271a6f813c4953faa618a230240812abe4b..ddc5f3dc97208048597c9d9ca550bdeb9e8bd845 100644
--- a/tests/testthat/test-Zalpha_BetaCDF.R
+++ b/tests/testthat/test-Zalpha_BetaCDF.R
@@ -332,3 +332,24 @@ test_that("Zalpha_BetaCDF calculates Zalpha_BetaCDF statistic correctly with mis
                                   NA,NA,NA,NA)
                ),tolerance=0.0001)
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zalpha_BetaCDF calculates Zalpha_BetaCDF statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zalpha_BetaCDF(pos = df1$POS, ws  = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_Beta_a = LDprofile$Beta_a, LDprofile_Beta_b = LDprofile$Beta_b, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zalpha_BetaCDF=c(NA,NA,NA,NA,
+                                  0.528754272440162,
+                                  0.554657151730784,
+                                  0.490365350771199,
+                                  0.429958093556324,
+                                  0.388665184297966,
+                                  0.396797658473664,
+                                  0.40379809759356,
+                                  NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})
diff --git a/tests/testthat/test-Zalpha_Zscore.R b/tests/testthat/test-Zalpha_Zscore.R
index a018afa248583bc2cf319224814091ec31a138de..5fb03f1c9905a93df3a95909d885b3dff5f35480 100644
--- a/tests/testthat/test-Zalpha_Zscore.R
+++ b/tests/testthat/test-Zalpha_Zscore.R
@@ -351,3 +351,25 @@ test_that("Zalpha_Zscore calculates Zalpha_Zscore statistic correctly with missi
                                  NA,NA,NA,NA)
                ),tolerance=0.0001)
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zalpha_Zscore calculates Zalpha_Zscore statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zalpha_Zscore(pos = df1$POS, ws  = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, LDprofile_sd = LDprofile$sd, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zalpha_Zscore=c(NA,NA,NA,NA,
+                                 0.171551248775495,
+                                 0.250751380960093,
+                                 0.0418726269555867,
+                                 -0.192722802223301,
+                                 -0.316679396412605,
+                                 -0.285401890619276,
+                                 -0.244931914193891,
+                                 NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})
+
diff --git a/tests/testthat/test-Zalpha_all.R b/tests/testthat/test-Zalpha_all.R
index 8240dbf03a491113c791de35e38940c81005f11c..6c6bd0f177fa64e789a5943aea4ebfd721bfd4a3 100644
--- a/tests/testthat/test-Zalpha_all.R
+++ b/tests/testthat/test-Zalpha_all.R
@@ -568,3 +568,29 @@ test_that("Zalpha_all calculates statistics correctly with missing value", {
                  Zbeta=c(NA,NA,NA,NA,0.248611111111111,0.235185185185185,0.233651620370370,0.257794784580499,0.250144675925926,0.259413580246914,0.271354166666667,NA,NA,NA,NA)
                ),tolerance=0.0001)
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zalpha_all calculates statistics correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zalpha_all(pos = df1$POS, ws  = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, LDprofile_sd = LDprofile$sd, LDprofile_Beta_a = LDprofile$Beta_a, LDprofile_Beta_b = LDprofile$Beta_b, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 LR=c(0,13,24,33,40,45,48,49,48,45,40,33,24,13,0),
+                 L_plus_R=c(91,78,67,58,51,46,43,42,43,46,51,58,67,78,91),
+                 Zalpha_expected=c(NA, NA, NA, NA, 0.35775270849344, 0.360194100145564, 0.36882454832507, 0.379040922949242, 0.400715520018796, 0.401718327864356, 0.388093039845692, NA, NA, NA, NA),
+                 Zbeta_expected=c(NA, NA, NA, NA, 0.309796639287645, 0.306356600239621, 0.299229117644403, 0.287619092597206, 0.271195118636169, 0.271195118636169, 0.285239698673566, NA, NA, NA, NA),
+                 Zalpha=c(NA, NA, NA, NA, 0.417052469135803, 0.449363425925926, 0.377521494708995, 0.298941798941799, 0.270709325396825, 0.281925154320988, 0.287615740740741, NA, NA, NA, NA),
+                 Zbeta=c(NA, NA, NA, NA, 0.256944444444444, 0.243827160493827, 0.244068287037037, 0.255243764172336, 0.241174768518518, 0.252314814814815, 0.261284722222222, NA, NA, NA, NA),
+                 Zalpha_rsq_over_expected=c(NA, NA, NA, NA, 1.19167472080619, 1.27358283231798, 1.05911709750039, 0.813967663774974, 0.691051112331195, 0.728230393808371, 0.76047497606951, NA, NA, NA, NA),
+                 Zalpha_log_rsq_over_expected=c(NA, NA, NA, NA, -0.0866699301333792, -0.0450984996562888, -0.170082829057599, -0.292011096473854, -0.355497049708911, -0.345346264723395, -0.325460796768333, NA, NA, NA, NA),
+                 Zbeta_rsq_over_expected=c(NA, NA, NA, NA, 0.829165822709247, 0.794411354588777, 0.811051641594364, 0.879635831191311, 0.8893035012259, 0.93038110746129, 0.936927121826222, NA, NA, NA, NA),
+                 Zbeta_log_rsq_over_expected=c(NA, NA, NA, NA, -0.253507645357523, -0.252472151393989, -0.264919235707824, -0.237790197768511, -0.231067956739982, -0.186686780456914, -0.194302291843375, NA, NA, NA, NA),
+                 Zalpha_Zscore=c(NA, NA, NA, NA, 0.171551248775495, 0.250751380960093, 0.0418726269555867, -0.192722802223301, -0.316679396412605, -0.285401890619276, -0.244931914193891, NA, NA, NA, NA),
+                 Zbeta_Zscore=c(NA, NA, NA, NA, -0.155023529432353, -0.185399969976716, -0.168250652582989, -0.104627764295373, -0.0955723675990356, -0.0601070717071691, -0.0618178441622676, NA, NA, NA, NA),
+                 Zalpha_BetaCDF=c(NA, NA, NA, NA, 0.528754272440162, 0.554657151730784, 0.490365350771199, 0.429958093556324, 0.388665184297966, 0.396797658473664, 0.40379809759356, NA, NA, NA, NA),
+                 Zbeta_BetaCDF=c(NA, NA, NA, NA, 0.459559291673423, 0.456100842212321, 0.459910029690557, 0.479549830626744, 0.482519290259401, 0.49506531210108, 0.488097958454476, NA, NA, NA, NA)
+               ),tolerance=0.0001)
+})
diff --git a/tests/testthat/test-Zalpha_expected.R b/tests/testthat/test-Zalpha_expected.R
index 635c5fe8dbc2f4f25b9233b45cf19586ffe41ee9..90b77b8ef3c32f49c3ce6d832f459eb03736003d 100644
--- a/tests/testthat/test-Zalpha_expected.R
+++ b/tests/testthat/test-Zalpha_expected.R
@@ -247,3 +247,24 @@ test_that("Zalpha_expected fails when LDprofile_bins and LDprofile_rsq are diffe
   expect_error(Zalpha_expected(pos = df$POS, ws  = 3000, dist = df$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = c(LDprofile$rsq,1), minRandL = 4, minRL = 25, X = NULL),
                "LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins")
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zalpha_expected calculates Zalpha_expected statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zalpha_expected(pos = df1$POS, ws  = 3000, dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zalpha_expected=c(NA,NA,NA,NA,
+                                   0.35775270849344,
+                                   0.360194100145564,
+                                   0.36882454832507,
+                                   0.379040922949242,
+                                   0.400715520018796,
+                                   0.401718327864356,
+                                   0.388093039845692,
+                                   NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})
diff --git a/tests/testthat/test-Zalpha_log_rsq_over_expected.R b/tests/testthat/test-Zalpha_log_rsq_over_expected.R
index b05466d89281ba3fdcaaec5c5fdb77501623fd26..d88cec7967dd3aa64fb17b61ffb365c4dda4a936 100644
--- a/tests/testthat/test-Zalpha_log_rsq_over_expected.R
+++ b/tests/testthat/test-Zalpha_log_rsq_over_expected.R
@@ -325,3 +325,24 @@ test_that("Zalpha_log_rsq_over_expected calculates Zalpha_log_rsq_over_expected
                                                 NA,NA,NA,NA)
                ),tolerance=0.0001)
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zalpha_log_rsq_over_expected calculates Zalpha_log_rsq_over_expected statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zalpha_log_rsq_over_expected(pos = df1$POS, ws  = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zalpha_log_rsq_over_expected=c(NA,NA,NA,NA,
+                                                -0.0866699301333792,
+                                                -0.0450984996562888,
+                                                -0.170082829057599,
+                                                -0.292011096473854,
+                                                -0.355497049708911,
+                                                -0.345346264723395,
+                                                -0.325460796768333,
+                                                NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})
diff --git a/tests/testthat/test-Zalpha_rsq_over_expected.R b/tests/testthat/test-Zalpha_rsq_over_expected.R
index 634c5ffb5ebb360d19b0e0cc960d379aee2fdad1..bc9d2e4026ed1838c61d170bb14cfe73d79abfd9 100644
--- a/tests/testthat/test-Zalpha_rsq_over_expected.R
+++ b/tests/testthat/test-Zalpha_rsq_over_expected.R
@@ -325,3 +325,24 @@ test_that("Zalpha_rsq_over_expected calculates Zalpha_rsq_over_expected statisti
                                             NA,NA,NA,NA)
                ),tolerance=0.0001)
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zalpha_rsq_over_expected calculates Zalpha_rsq_over_expected statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zalpha_rsq_over_expected(pos = df1$POS, ws  = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zalpha_rsq_over_expected=c(NA,NA,NA,NA,
+                                                1.19167472080619,
+                                                1.27358283231798,
+                                                1.05911709750039,
+                                                0.813967663774974,
+                                                0.691051112331195,
+                                                0.728230393808371,
+                                                0.76047497606951,
+                                                NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})
diff --git a/tests/testthat/test-Zbeta_BetaCDF.R b/tests/testthat/test-Zbeta_BetaCDF.R
index 580d35e85232461b8eb17c6752db2d4c1512f8b9..079cf9b3c542c758e5cb0812f3ca05a5b3b5e8d4 100644
--- a/tests/testthat/test-Zbeta_BetaCDF.R
+++ b/tests/testthat/test-Zbeta_BetaCDF.R
@@ -332,3 +332,24 @@ test_that("Zbeta_BetaCDF calculates Zbeta_BetaCDF statistic correctly with missi
                                  NA,NA,NA,NA)
                ),tolerance=0.0001)
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zbeta_BetaCDF calculates Zbeta_BetaCDF statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zbeta_BetaCDF(pos = df1$POS, ws  = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_Beta_a = LDprofile$Beta_a, LDprofile_Beta_b = LDprofile$Beta_b, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zbeta_BetaCDF=c(NA,NA,NA,NA,
+                                 0.459559291673423,
+                                 0.456100842212321,
+                                 0.459910029690557,
+                                 0.479549830626744,
+                                 0.482519290259401,
+                                 0.49506531210108,
+                                 0.488097958454476,
+                                 NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})
diff --git a/tests/testthat/test-Zbeta_Zscore.R b/tests/testthat/test-Zbeta_Zscore.R
index b1ef29d51cc8e8a6bf4c1aa38a4ade1b883e264a..6d940da30cccf7c133f3b38c3e373769f7ac71d2 100644
--- a/tests/testthat/test-Zbeta_Zscore.R
+++ b/tests/testthat/test-Zbeta_Zscore.R
@@ -351,3 +351,24 @@ test_that("Zbeta_Zscore calculates Zbeta_Zscore statistic correctly with missing
                                 NA,NA,NA,NA)
                ),tolerance=0.0001)
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zbeta_Zscore calculates Zbeta_Zscore statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zbeta_Zscore(pos = df1$POS, ws  = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, LDprofile_sd = LDprofile$sd, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zbeta_Zscore=c(NA,NA,NA,NA,
+                                -0.155023529432353,
+                                -0.185399969976716,
+                                -0.168250652582989,
+                                -0.104627764295373,
+                                -0.0955723675990356,
+                                -0.0601070717071691,
+                                -0.0618178441622676,
+                                NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})
diff --git a/tests/testthat/test-Zbeta_expected.R b/tests/testthat/test-Zbeta_expected.R
index 8a499b8b77513da8d53d2cc0411b7fd4d3a09390..6dce102d6dfda4f9b5e1ecf83bfdc1453a757fa4 100644
--- a/tests/testthat/test-Zbeta_expected.R
+++ b/tests/testthat/test-Zbeta_expected.R
@@ -247,3 +247,25 @@ test_that("Zbeta_expected fails when LDprofile_bins and LDprofile_rsq are differ
   expect_error(Zbeta_expected(pos = df$POS, ws  = 3000, dist = df$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = c(LDprofile$rsq,1), minRandL = 4, minRL = 25, X = NULL),
                "LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins")
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zbeta_expected calculates Zbeta_expected statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zbeta_expected(pos = df1$POS, ws  = 3000, dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zbeta_expected=c(NA,NA,NA,NA,
+                                  0.309796639287645,
+                                  0.306356600239621,
+                                  0.299229117644403,
+                                  0.287619092597206,
+                                  0.271195118636169,
+                                  0.271195118636169,
+                                  0.285239698673566,
+                                  NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})
+
diff --git a/tests/testthat/test-Zbeta_log_rsq_over_expected.R b/tests/testthat/test-Zbeta_log_rsq_over_expected.R
index d7f841ec3097adb97dd0183fd7459ab21f767355..cc50f4d29dc830d1c4a624acef151c57335ec596 100644
--- a/tests/testthat/test-Zbeta_log_rsq_over_expected.R
+++ b/tests/testthat/test-Zbeta_log_rsq_over_expected.R
@@ -325,3 +325,24 @@ test_that("Zbeta_log_rsq_over_expected calculates Zbeta_log_rsq_over_expected st
                                                NA,NA,NA,NA)
                ),tolerance=0.0001)
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zbeta_log_rsq_over_expected calculates Zbeta_log_rsq_over_expected statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zbeta_log_rsq_over_expected(pos = df1$POS, ws  = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zbeta_log_rsq_over_expected=c(NA,NA,NA,NA,
+                                               -0.253507645357523,
+                                               -0.252472151393989,
+                                               -0.264919235707824,
+                                               -0.237790197768511,
+                                               -0.231067956739982,
+                                               -0.186686780456914,
+                                               -0.194302291843375,
+                                               NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})
diff --git a/tests/testthat/test-Zbeta_rsq_over_expected.R b/tests/testthat/test-Zbeta_rsq_over_expected.R
index 5020ba48f8cdef5223f8ff60488b08010f0df991..74438efce1475506afa9412f3040d1e64366e49f 100644
--- a/tests/testthat/test-Zbeta_rsq_over_expected.R
+++ b/tests/testthat/test-Zbeta_rsq_over_expected.R
@@ -325,3 +325,24 @@ test_that("Zbeta_rsq_over_expected calculates Zbeta_rsq_over_expected statistic
                                            NA,NA,NA,NA)
                ),tolerance=0.0001)
 })
+
+## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
+
+df1<-df
+df1$dist[10:15]<-df1$dist[10:15]+0.1
+test_that("Zbeta_rsq_over_expected calculates Zbeta_rsq_over_expected statistic correctly when biggest bin is bigger than LDprofile", {
+
+  expect_equal(Zbeta_rsq_over_expected(pos = df1$POS, ws  = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL),
+               list(
+                 position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500),
+                 Zbeta_rsq_over_expected=c(NA,NA,NA,NA,
+                                           0.829165822709247,
+                                           0.794411354588777,
+                                           0.811051641594364,
+                                           0.879635831191311,
+                                           0.8893035012259,
+                                           0.93038110746129,
+                                           0.936927121826222,
+                                           NA,NA,NA,NA)
+               ),tolerance=0.0001)
+})