Add E2E test and fix some issues