GWTII-131: added unit tests + some small fixes