change upsert method to sync and fix parameter type annotation
fix typo in switch condition to check browser env loading
add metadata upsert test case