Make Database take a block and actually close it

The rest was reordered accordingly
Add specs

The access time stuff is not tested yet.
Add rubocop
Set rubocop line length to 99 chars max
Added rubocop suggestions
added a few doccomments