Fixed some async issues, and added more tests.