added fixes and tests