Added the testing and fixed API call bugs and deadlock bug