Double check all the connections and the battery mount. One of my favorite tools is called 'Strap-On'. It is a rubber strap with a clip. Sometimes on loose batteries you can strap it on and the problem goes away when testing over cobbles. Then you just need to tighten the battery mount. Problem solved. This often requires a pliable shim install even on high-end new Specialized bikes. I also use it for floppy forks when installing motorcycle type front wheels on moped style bikes, or when a bike is upside down for a new controller and needs some additional support so you can push against the stand without rotating the bike. Sometimes a strap on is what it takes to make for satisfaction in the eBike world. A section of an old tube can serve just as well. It can hold the brake lever while it is adjusted. Application of some dielectric grease may also be in order.