Fix tests, thanks @manishtomar
Move some code around, thanks @manishtomar