Adding security tests and fixing security bugs