small fixes, added tests