extract bundler api out of index.js + add tests