added functions, fixed tests