Code review changes.

Fixed handler issues and api tests from code review
from @minrk and @carreau.