add toggle handling and fix async test errors