Fix and refactor methods in database class. Add sites addition with unique code

Fixes #14 
This action should be protected from guest users. For example, it could redirect users to the login page with an explanatory flash message.

Write a test case before fixing this.

This section of the documentation will be helpful during implementation: http://www.sinatrarb.com/intro.html#Filters