Test fixes
Code improvements