Fixed some bugs and missing functionality; added synchronous test case.