bug fixed optmised .tested, need to test with main application