Fix replacing data-main when using require.js

Code change with tests for cases where we are using a data-main attribute for a require.js application. This ensures that the data-main tag is preserved and updated with the specified js file.