Testing JS: If method exists