now really re-factored,simplified,added proper json-parsing,expanded examples and tests