added tests, and better async