diff --git a/libcelt/bands.c b/libcelt/bands.c
index 68193a6d81a50faac466884048dd9f3463ec68d7..7cdfd1780cdd61a404b721fae2c0fe8994997324 100644
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -53,12 +53,10 @@ static opus_int16 bitexact_cos(opus_int16 x)
    opus_int32 tmp;
    opus_int16 x2;
    tmp = (4096+((opus_int32)(x)*(x)))>>13;
-   if (tmp > 32767)
-      tmp = 32767;
+   celt_assert(tmp<=32767);
    x2 = tmp;
    x2 = (32767-x2) + FRAC_MUL16(x2, (-7651 + FRAC_MUL16(x2, (8277 + FRAC_MUL16(-626, x2)))));
-   if (x2 > 32766)
-      x2 = 32766;
+   celt_assert(x2<=32766);
    return 1+x2;
 }
 
diff --git a/libcelt/tests/mathops-test.c b/libcelt/tests/mathops-test.c
index d15fcebf35ecc3b1ce338cf48fc6752009fa07b7..ef25f5d0600c722531b4c3382a4f9d6bd3fa08ea 100644
--- a/libcelt/tests/mathops-test.c
+++ b/libcelt/tests/mathops-test.c
@@ -68,7 +68,7 @@ void testbitexactcos(void)
    opus_int32 min_d,max_d,last,chk;
    chk=max_d=0;
    last=min_d=32767;
-   for(i=0;i<16385;i++)
+   for(i=64;i<=16320;i++)
    {
       opus_int32 d;
       opus_int32 q=bitexact_cos(i);
@@ -78,8 +78,8 @@ void testbitexactcos(void)
       if (d<min_d)min_d=d;
       last = q;
    }
-   if ((chk!=91017006)||(max_d!=5)||(min_d!=0)||(bitexact_cos(0)!=32767)||
-       (bitexact_cos(16384)!=1)||(bitexact_cos(8192)!=23171))
+   if ((chk!=89408644)||(max_d!=5)||(min_d!=0)||(bitexact_cos(64)!=32767)||
+       (bitexact_cos(16320)!=200)||(bitexact_cos(8192)!=23171))
    {
       fprintf (stderr, "bitexact_cos failed\n");
       ret = 1;
@@ -91,8 +91,8 @@ void testbitexactlog2tan(void)
    int i,fail;
    opus_int32 min_d,max_d,last,chk;
    fail=chk=max_d=0;
-   last=min_d=30690;
-   for(i=0;i<8193;i++)
+   last=min_d=15059;
+   for(i=64;i<8193;i++)
    {
       opus_int32 d;
       opus_int32 mid=bitexact_cos(i);
@@ -106,8 +106,8 @@ void testbitexactlog2tan(void)
       if (d<min_d)min_d=d;
       last = q;
    }
-   if ((chk!=16578548)||(max_d!=3219)||(min_d!=-2)||fail||
-       (bitexact_log2tan(32767,1)!=30690)||(bitexact_log2tan(30274,12540)!=2611)||
+   if ((chk!=15821257)||(max_d!=61)||(min_d!=-2)||fail||
+       (bitexact_log2tan(32767,200)!=15059)||(bitexact_log2tan(30274,12540)!=2611)||
        (bitexact_log2tan(23171,23171)!=0))
    {
       fprintf (stderr, "bitexact_log2tan failed\n");