Why does my cost either increase or go down very slowly
I would refer you to this website that provides a very extensive and detailed walk through the math behind the logistic regression and it's cost function.
https://www.internalpointers.com/post/cost-function-logistic-regression

And here is a complete tutorial on how to manually code the whole thing in python:

https://towardsdatascience.com/building-a-logistic-regression-in-python-301d27367c24

Finally, I don't know the reason you need to implement this manually, there are pretty good ready-to-use functions that have been used and tested and that would save you a lot of time.

Good luck !