Building JS Functions and tests