updated code, added example
fixed tests