Code reorg & tests

Moved metrics_handler.rb to lib dir
Added bin/metrics_handler
Added unit tests