Database integration

database integration, message saving, integration tests