Add c3p0 config, clean code, fix tests