fixed renderElements, now it renders all elements correctly
- improved js-code and tests