Code formatting
Properly escape all variables before outputting

see esc_url, esc_attr, esc_html & esc_js
Move the filter to the bottom where it should be
Fix some unit tests