Add main function

Move code under name == main to main function. Added tests to main
Add main function
Remove unittest class
Add sys.exit()