Make javascript more testable