Bug in offlinePouch Code, add karma tests