code for issue 18 + integration test