Refactor javascript tests