fix type conversion
add tests
add event
restruct variable lib