Computing two-electron integrals with an STO-3G basis set
Actually there is a mistake in the analtical expression in Cook's Book. On his web page he has a pdf with the corrected verison

http://spider.shef.ac.uk/

Maybe this solves your problem, but I would also recommend to implement the Obara-Saika Scheme or rys-Quadrature since they are really much more efficient. If your are programming in Python, you might have a look at the PyQuante project, which implements all this stuff. 
Concerning Obara-Saika you might also read about the Head-Gordon Pople Scheme. It is in principial an adapted version of Obara-Saika which reduces the FLOP count.