implement #50
add tests for #50