Added tests and fixes to support authorization code grant (http://tools.ietf.org/html/rfc6749#section-4.1)