added APM js impl; refactored test code; improved doc