More tests.
Convert discrete attributes when fetching them from database.
Tests for reading values from sql.
Fixed a failing test.

_create_attributes now returns a tuple.