Added public key parameter and improved tests