Refactor Karma testing and build configuration