added asynchronous functionality, tests adapted