Some new functions and more tests