Moved index.js to top level and fixes any issues in tests