added print function, fixed more bugs, some tests