add tests and small fixes