Various fixes and improvements - especially PostgreSQL

 * various fixes, also for PostgreSQL
 * cast number to int
 * use correct sql statement for checking for albums
 * unit test for case when album is null
 * move casting to appframework entity
 * remove blank lines
Merge pull request #88 from owncloud/various-fixes

various fixes for postgres