added tests, fixed async issue in lib