Adding cov tests and fixing some bugs