WIP add spec and fix dialyzer errors and warning