migrated code from charon + fixed some bugs
added tests
cleaning some imports