fix possible npe
use mockito for all subprojects
update p5 event listener, fix possible npe, add unit test
make toggle mode synchronized