add more test assertions
and do more refactoring covered by tests