Implement functions.
Added "__main__" field.
Added testing.
Fixed bug and errors in test files.
Used unittest for testing.