cleaned crypto library and test functions