code clean-up, added test data and tests