Fix export function #47 and #48

for review, unit tests added.