Refactoring and adding unit tests
Added test and dropped curl usage in exchange to library