Api unit tests fixes #164 and #161