Add more tests and fixes

Signed-off-by: Vlad Velici <vlad.velici@gmail.com>