and add unit tests for them. Signed-off-by: Daniel Nephin <dnephin@docker.com> (cherry picked from commit c26e7d8c9105e16048268a01dd1e556af43902cd)