KAZOO-3086: use save_attachment/3 and add specs
KAZOO-3086: refactor a bit to clean up functions