added upsert test and more javadoc