remove unused logic and add tests