Add bit extend module and fix some bugs found in test