refactored library to implement compact protocol and added unit testing suite