added cosine, improved tests