code clean-up
added a functional test