rewrote tests
added bug_rsa_order test

Refactored some parts of script